Set Print Range & Custome Footer (Page No.) in Excel Sheet

I'm trying to create an excel file ready to print.

I've set header rows using 

ws.PageSetup.PrintTitleRows = $"$1:$4";

  1. Now I want to display Page No. at the bottom (footer) of page. How to do it ?
  2. I want to set Print Area using available range (StartRow, StartColumn, LastRow, LastColumn) Index
  3. Also, I want to show user Print Preview
Can you please help me.






9 Replies

RS Ramya Sivakumar Syncfusion Team September 12, 2022 11:32 AM UTC

Hi Amit,


Greetings from Syncfusion.


Please find the response to the queries in the below table.


Query

 

Response

Now I want to display Page No. at the bottom (footer) of page. How to do it ?

 

Kindly use the following code snippet to set the page number at the footer.

 

Code snippet:

 

ws.PageSetup.CenterFooter = "&P";

 

Please refer to the following links to know more about the header and footer.

 

https://help.syncfusion.com/file-formats/xlsio/faqs/how-to-set-or-format-a-header-footer

 

https://www.syncfusion.com/kb/1933/add-excel-headers-and-footers-in-c-vb-net

 

 

I want to set Print Area using available range (StartRow, StartColumn, LastRow, LastColumn) Index

 

The following code snippet is used to set the print area using the Used Range kindly try this and let us know if it helps.

 

Code snippet:

 

ws.PageSetup.PrintArea = ws.UsedRange.AddressLocal;

 

 

Also, I want to show user Print Preview

 

Please use the following code snippet to set the print preview option.

 

Code snippet:

 

ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

converter.Print();              

 

Kindly refer to the following link to learn more about the print option.

https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-conversion#print-excel-document

 

 



Regards,

Ramya



AS Amit Saraf September 13, 2022 05:40 AM UTC

Thanks for your reply

following helped me


ws.PageSetup.CenterFooter = "&P";
ws.PageSetup.PrintArea = ws.UsedRange.AddressLocal;

I want to show PrintPreview of how the document would be printed and let user decide about rest.


ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
converter.Print();


This directly prints to printer.




RS Ramya Sivakumar Syncfusion Team September 18, 2022 10:55 AM UTC

Hi Amit,


You’re welcome. We are glad that the provided suggestion helped you.


We have prepared the sample to get the print preview of the file. kindly try this and let us know if the solution helps.


Sample link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample104096141


Regards,

Ramya



AS Amit Saraf September 19, 2022 06:12 AM UTC

Thanks for your reply,

This process needs to convert excel file to pdf file and open it in PdfViewer Control or can be opened in any other PDF Viewer Installed on machine

Isn't there any way that I can show print preview of excel file without converting it to pdf?

Also is there any way I can add Save As & Print button to PdfViewer Toolbar instead of showing it in menu (refer attached image)

Optinons.jpg

Thanks for help



RS Ramya Sivakumar Syncfusion Team September 22, 2022 04:56 AM UTC

Hi Amit,


Query

Response

 

There any way that I can show print preview of excel file without converting it to pdf?

Unfortunately, it is not possible to get the print preview without converting the Excel to PDF.

 

Also is there any way I can add Save As & Print button to PdfViewer Toolbar instead of showing it in menu (refer attached image)

We are checking the issue with concerned team and we will provide the further details on or before September 23, 2022.



Regards,

Ramya




AS Amit Saraf September 22, 2022 05:28 AM UTC

Thanks for your reply.


  1. Hope Option to show print preview without converting excel to pdf would be incorporated in future releases.
  2. Waiting eagerly for reply from concerned team regarding option for showing Save As & Print buttons in PdfViewer Control.

Thanks a lot





RS Ramya Sivakumar Syncfusion Team September 23, 2022 02:08 PM UTC

Hi Amit,


Query

Response

 

Hope Option to show print preview without converting excel to pdf would be incorporated in future releases. 

As mentioned earlier, it is not possible to get the print preview without converting the Excel to PDF

Waiting eagerly for reply from concerned team regarding option for showing Save As & Print buttons in PdfViewer Control.

 


We have prepared the sample to showing Save As & Print buttons in PdfViewer. kindly try this and let us know if the solution helps.

 

Sample link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/F-1774181747355047.zip

 



Regards,

Ramya



AS Amit Saraf September 26, 2022 06:55 AM UTC

It Worked

Thanks a lot



RS Ramya Sivakumar Syncfusion Team September 27, 2022 08:11 AM UTC

Hi Amit,


You're Welcome.


We are glad that the provided suggestion helped you. Kindly let us know if you need any further assistance.


Regards,

Ramya


Loader.
Up arrow icon