Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Mar 06, 2024 6:44 am

When converting to pdf, part of the table remains on the previous sheet, marked in color. Is there any way to customize the table transfer like when converting via Excel?
Attachments
questions_to_supp.rar
(441.86 KiB) Downloaded 451 times
spire_q01.PNG
spire_q01.PNG (64.01 KiB) Viewed 5406 times

Kostegan
 
Posts: 6
Joined: Wed Sep 01, 2021 8:09 am

Wed Mar 06, 2024 7:33 am

Hello,

Thank you for your inquiry.
To implement the requirements you mentioned, please use the following code snippet:
Code: Select all
Workbook workbook = new Workbook();
workbook.loadFromFile("Ex01_xxx.xlsx");
for (int i = 0; i < workbook.getWorksheets().getCount(); i++) {
    Worksheet worksheet = workbook.getWorksheets().get(i);
    worksheet.getPageSetup().setPaperSize(PaperSizeType.PaperA4);
    worksheet.getPageSetup().setTopMargin(0.5);
    worksheet.getPageSetup().setBottomMargin(0.5);
}
workbook.saveToFile("result.pdf", FileFormat.PDF);

If you encounter any issues or require further assistance while implementing this code, please feel free to reach out to us.

Sincerely,
Annika
E-iceblue support team
Attachments
result.zip
(86.3 KiB) Downloaded 482 times
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS