X - Another custom print question?

Hi,
I want to print from closed file, can I have some of these options? 
range.print // specify range
worksheet.print // all page in specify worksheet
workbook.print // all page in all worksheets
thanks you!

28 Replies

SK Shamini Kiruba Sobers Syncfusion Team May 28, 2020 10:20 AM UTC

Hi Khanh Dang, 

Greetings from Syncfusion. 

You can load an Excel workbook and print either a specific worksheet or the whole workbook. Kindly refer the following link for the same. 

But, there is no option to print a specific range. You can copy the range to a new sheet and print worksheet with the range as below. 

Code snippet: 

Using excelEngine As ExcelEngine = New ExcelEngine() 
    'Instantiate the application object 
    Dim application As IApplication = excelEngine.Excel 
 
    'Open the template workbook with dummy data 
    Dim workbook As IWorkbook = application.Workbooks.Open("Input.xlsx", ExcelOpenType.Automatic) 
 
    'Accessing the first worksheet and range to print 
    Dim worksheet As IWorksheet = workbook.Worksheets(0) 
    Dim sourceRange As IRange = worksheet.Range("A1:L12") 
 
    'Create a new worksheet and copy the range 
    Dim worksheet1 As IWorksheet = workbook.Worksheets.Create("NewSheet") 
    Dim destinationRange As IRange = worksheet1.Range("A1:L12") 
    sourceRange.CopyTo(destinationRange, ExcelCopyRangeOptions.All) 
 
    'Print the worksheet with the range 
    Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(worksheet1) 
    converter.Print() 
End Using 

Kindly let us know if this helps. 

Regards, 
Shamini 



TG The GridLock May 29, 2020 12:44 PM UTC

Hi Shamini,
I haven't tested it right now, I still have some questions, so I'll respond as soon as I can!


SK Shamini Kiruba Sobers Syncfusion Team May 29, 2020 01:11 PM UTC

Hi Khanh Dang, 

We will wait to hear from you. 

Regards, 
Shamini 



TG The GridLock May 30, 2020 08:09 AM UTC

Hi Shamini, 
question1a: I have seen the papersize option, but does syncfusion have a built-in name lister and am I just calling the name instead of looking up and converting? Something like this? (
question1b: Can I print only charts or embedded charts?
question1c: if i print entire workbook, how i can custom zoom page?
question1d: Is there any difference between sheet.zoom=120 and pdfview...ScalePercentage = 120?
question2: Why are they(pdforientation and pdfviewprintorientation enum not equals) with each other?

question3: can you explain more excel2pdf not support Row and column headings mean? because I see in sheet.pagesetup still have printgridline / printheading?
question4: I have many of the same settings for sheets in same workbook(not all), when loop printing can I use a template pagesetup or do I still have to set up all settings for each sheet?.


SK Shamini Kiruba Sobers Syncfusion Team June 1, 2020 12:59 PM UTC

Hi Khanh Dang, 

Kindly find the response for your queries from the following table. 

Query 
Response 
question1a: I have seen the papersize option, but does syncfusion have a built-in name lister and am I just calling the name instead of looking up and converting? Something like this? 
Kindly make use of the ExcelPaperSize enumeration for your requirement. 
question1b: Can I print only charts or embedded charts? 
Yes, you can print a chart by using the following code snippet. 

Code snippet: 

Using excelEngine As ExcelEngine = New ExcelEngine() 
    'Instantiate the application object  
    Dim application As IApplication = excelEngine.Excel 
 
    'Initialize chart to image converter 
    application.ChartToImageConverter = New ChartToImageConverter() 
    application.ChartToImageConverter.ScalingMode = ScalingMode.Best 
 
    'Open the workbook that contains chart 
    Dim workbook As IWorkbook = application.Workbooks.Open("ChartInput.xlsx", ExcelOpenType.Automatic) 
 
    'Accessing the first worksheet 
    Dim worksheet As IWorksheet = workbook.Worksheets(0) 
 
    'Accessing the chart to print 
    Dim chart As IChart = worksheet.Charts(0) 
 
    'Print the chart  
    Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(chart) 
    converter.Print() 
End Using 


question1c: if i print entire workbook, how i can custom zoom page? 
When printing entire workbook, the following code snippet helps in custom zooming. 

Code snippet: 

For Each worksheet In workbook.Worksheets 
    worksheet.PageSetup.Zoom = 120 
Next 


question1d: Is there any difference between sheet.zoom=120 and pdfview...ScalePercentage = 120? 
sheet.Zoom property is used when you want the saved Excel workbook to be zoomed. 
sheet.PageSetup.Zoom is used when you want the converted/printed PDF document to be zoomed. 
pdfViewer.PrinterSettings.ScalePercentage is used when you load a PDF document using PDFViewer control and print using PrinterSettings in it. 

question2: Why are they(pdforientation and pdfviewprintorientation enum not equals) with each other? 
 

PdfPageOrientation is used to set the page orientation (Portrait or Landscape) while creating the PDF document.   
  
Note: Default value of this Enum is Portrait.  
  
PdfViewerPrintOrientation is related to the orientation of the printed output paper dimensions. Since the printed output paper dimension is not related to the PDF page dimension, their values are not necessary to be equal. However, you can set the required orientation to the printer settings property. Please refer to the UG link below.  
question3: can you explain more excel2pdf not support Row and column headings mean? because I see in sheet.pagesetup still have printgridline / printheading? 
PrintHeadings property is applicable to show or hide heading in Excel workbooks and this support is not  available in PDF conversion. 
question4: I have many of the same settings for sheets in same workbook(not all), when loop printing can I use a template pagesetup or do I still have to set up all settings for each sheet? 
Template PageSetup for an workbook is not available. You need to set up the PageSetup options for each sheet in a single ForEach loop, as we did in the code given for custom zoom page. 

Kindly let us know whether the provided solutions helped you. 

Regards, 
Shamini 



TG The GridLock June 2, 2020 08:40 AM UTC

Hi,
i have new question x.1: can i display total page number in printpreviewdialog?
question x.2: how to disable print button on printpreviewdialog?
question x.3: can access event mouse_wheel on printpreviewdialog?


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team June 2, 2020 04:03 PM UTC

Hi Khanh Dang, 

We have documented all the supported print settings in the following link. 

Apart from these, other settings that you have asked now cannot be modified within XlsIO.

Kindly let us know whether you want to do these settings from XlsIO or PDFViewer. Please note that, these settings are not possible with XlsIO control and if you want any information regarding PDFViewer, please create a new incident/forum under PDFViewer control. 

Regards, 
Shamini.


TG The GridLock June 2, 2020 06:39 PM UTC

Hi Konduru,
Maybe I didn't notice this. Thanks for the reminder.


SK Shamini Kiruba Sobers Syncfusion Team June 3, 2020 08:57 AM UTC

Hi Khanh Dang, 

Thanks for the update. 

Regards, 
Shamini 



TG The GridLock June 4, 2020 10:39 PM UTC

Hi Shamini,
how to automatic set orientation of Ichartshape?, such as:
if chart.height > chart.width then
.orientation = portraint
else
.orientation=lanspcape
end if
Also if I want to reset pagesetup.PrintTitleRows to "default" what should I do? (i try: pagesetup.PrintTitleRows"" but i get an error) and
with question 1b: can i print Ichartshape as your code provide?


TG The GridLock June 5, 2020 04:44 AM UTC

my sample file from 1.b(print to pdf). Can you try it for me please?. When I loaded into pdfviewcontrol it was an empty file


Attachment: Print_32e90b5d.rar


SK Shamini Kiruba Sobers Syncfusion Team June 5, 2020 02:52 PM UTC

Hi Khanh Dang, 

Kindly find the response for your queries from the following table. 

Query 
Response 
how to automatic set orientation of Ichartshape?, such as: 
if chart.height > chart.width then 
.orientation = portraint 
else 
.orientation=lanspcape 
end if 

It is not possible to set orientation of IChartShape. You can set orientation to worksheet PageSetup with ExcelPageOrientation enumeration as below. 

worksheet.PageSetup.Orientation = ExcelPageOrientation.Landscape 
 
Also if I want to reset pagesetup.PrintTitleRows to "default" what should I do? (i try: pagesetup.PrintTitleRows"" but i get an error) 

You can set PrintTitleRows property to string in A1-style notation alone, which means you can refer to a cell or a range of cells. Also, we are not facing any error on setting empty string. Kindly share us the code used and the error details for further analysis. 
and 
with question 1b: can i print Ichartshape as your code provide? 

Yes, you can print with IChartShape objects too. 
my sample file from 1.b(print to pdf). Can you try it for me please?. When I loaded into pdfviewcontrol it was an empty file 

The given sample file is properly converted to PDF with ExcelToPDFConverter and charts in the file are also getting printed properly. Kindly ensure whether you have initialized ChartToImageConverter as below to print charts. 

application.ChartToImageConverter = New ChartToImageConverter() 

Also, kindly confirm us whether you are using ExcelToPDFConverter or PDFViewer code. If you are still facing the issue, kindly share us the code snippet that you are using at your end, so that we can give prompt solution at the earliest. 


Regards, 
Shamini 



TG The GridLock June 5, 2020 09:15 PM UTC

Hi Shamini,
1. It is not possible to set orientation of IChartShape.
yes, so  Can I access its height and width of IChartshape so that I can set pagesetup.orientation?
2. I have problems with printtilerow = "" when print to pdf.
3,4 Sorry I forgot to mention printing them to pdf. (not convert.print ())
Can you confirm again that they work? 
Thanks!


SK Shamini Kiruba Sobers Syncfusion Team June 8, 2020 01:21 PM UTC

Hi Khanh Dang, 

Please find the response for your queries below. 

Query 
Response 
1. It is not possible to set orientation of IChartShape. 
yes, so  Can I access its height and width of IChartshape so that I can set pagesetup.orientation? 

We are checking this requirement and will let you know the details on June 9th, 2020. 
I have problems with printtilerow = "" when print to pdf. 
Kindly share us the issue reproducing sample as requested in our previous update, which will be helpful for us in investigating the query. 
3,4 Sorry I forgot to mention printing them to pdf. (not convert.print ()) 
Excel charts can alone be converted to PDF, by initializing ChartToImageConverter and parsing the chart object in ExcelToPdfConverter. 

Please look into the code below. 

application.ChartToImageConverter = new ChartToImageConverter(); 
ExcelToPdfConverter converter = new ExcelToPdfConverter(chart); 

If you still face any issue, kindly share us the issue reproducing sample. 

Regards, 
Shamini 



TG The GridLock June 8, 2020 10:48 PM UTC

Hi Shamini,
Great! more question:
Can i custom this?
Real Image:

but after convert to pdf:

I tried this but it didn't change?
For Each ch As IChartShape In ws0.Charts
                    With ch.PageSetup
                        .Zoom = 50
                        .FitToPagesTall = 1
                        .FitToPagesWide = 1
                    End With
Next ch



SK Shamini Kiruba Sobers Syncfusion Team June 9, 2020 03:39 PM UTC

Hi Khanh Dang, 

We are validating the difference found between Excel input and PDF output. There could be an issue. We will share the validation details on June 11th, 2020

Regards, 
Shamini 



SK Shamini Kiruba Sobers Syncfusion Team June 11, 2020 01:07 PM UTC

Hi Khanh Dang, 

We have already logged a defect report about this issue as Chart title with wrapped text is rendered improper in chart to image conversion for the changes in chart title text after conversion. The fix for this issue will be available on June 24th, 2020. Kindly confirm the version you are using, so that we will provide patch in that version. You can track the status of the issue through the following link. 


We suggest you to use the below code snippet to resolve other changes in the output chart. 

Code snippet: 

chart.PrimaryValueAxis.MinimumValue = 0.0 
chart.PrimaryValueAxis.MaximumValue = 1.0 
chart.PrimaryValueAxis.MinorUnit = 0.02 
chart.PrimaryValueAxis.MajorUnit = 0.1 

Kindly let us know if this helps. 

Regards, 
Shamini 



TG The GridLock June 11, 2020 06:40 PM UTC

Hi Shamini,
my version is 18.0.142


SK Shamini Kiruba Sobers Syncfusion Team June 12, 2020 01:17 PM UTC

Hi Khanh Dang, 

18.0.142 is not a valid version. Kindly confirm whether you are using the version 18.1.0.42 for XlsIO. 

Regards, 
Shamini 



TG The GridLock June 12, 2020 01:34 PM UTC

Hi Shamini,
I was wrong. exactly 18.1.0.42 !


SK Shamini Kiruba Sobers Syncfusion Team June 12, 2020 02:48 PM UTC

Hi Khanh Dang, 

Thanks for the update. 

Hope, one of the chart issues in the converted PDF has been resolved with the given code. We will provide patch for the issue with rendering the wrapped chart title text in version v18.1.0.42 on June 24th, 2020 as promised earlier. 


Regards, 
Shamini 



TG The GridLock June 12, 2020 06:38 PM UTC

 Hi Shamini, Can I access height and width of IChartshape? andalso, can i import from excelfile with a defined area to datagrid but they contain images (in each row).
as this:




SK Shamini Kiruba Sobers Syncfusion Team June 15, 2020 12:25 PM UTC

Hi Khanh Dang, 

Kindly find the response for your queries from the following table. 

Query 
Response 
Can I access height and width of IChartshape? 
You can access height and width of IChartShape using any of the following code snippets. 

Code snippets: 

TryCast(chart, IChart).Height = 1000.5 
TryCast(chart, IChart).Width = 1000.5 

(or) 

TryCast(chart, IShape).Height = 1000 
TryCast(chart, IShape).Width = 1000 


can i import from excelfile with a defined area to datagrid but they contain images (in each row). 
Kindly look into the following KB to export Excel to DataGrid. 

But, we don’t have support to export images in an Excel file to DataGrid. 


Regards, 
Shamini 



TG The GridLock June 22, 2020 09:31 AM UTC

Ok Shamini, 
I have new question: Can I read files saved in the onedrive folder? Its link like this: https: //d.docs.live.net/154e2f875e6c1bfc/EXCEL/FILE%20.XLSX/Test%20formula.xlsx. .;


SK Shamini Kiruba Sobers Syncfusion Team June 23, 2020 01:50 PM UTC

Hi Khanh Dang, 

Kindly look into the following KB that may fulfill your requirement. 

Regards, 
Shamini 



SK Shamini Kiruba Sobers Syncfusion Team June 24, 2020 03:07 PM UTC

Hi Khanh Dang, 

We have fixed the issue Chart title with wrapped text is rendered improper in chart to image conversion and generated patch in the version v18.1.0.42. The patch with fix to resolve the reported issue can be downloaded from the following link. 


Recommended approach - exe will perform automatic configuration       
   
Please find the patch setup from below location:  
       
Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment       
   
Please find the patch assemblies alone from below location: 

     
Assembly Version: 18.1.0.42 

Installation Directions :        
This patch should replace the files “Syncfusion.ExcelChartToImageConverter.Wpf” under the following folder. 
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.6        
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\18.1.0.42\precompiledassemblies\18.1.0.42\4.6  
       
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.       
       
Note :        
You can change how you receive bug fixes by navigating to the following link and updating your preferences.        
    
Disclaimer :   
Please note that we have created this patch for version 18.1.0.42 specifically to resolve the issues reported in forum 154636.      
              
If you have received other patches for the same version for other products, please apply all patches in the order received.       
      
This fix will be included in our release version 18.2 which will be rolled out by 1st week of July 2020.  

Regards,     
Shamini 



TG The GridLock June 24, 2020 04:20 PM UTC

Thanks Shamini,
I will check it coming.


SK Shamini Kiruba Sobers Syncfusion Team June 25, 2020 11:04 AM UTC

Hi Khanh Dang, 

Thanks for the update. We will wait to hear from you. 

Regards, 
Shamini 


Loader.
Up arrow icon