I’m looking for a way to convert an excel file to one pdf that contains the entire workbook.
In Excel there are these pulishing options (see attachment).
publishOptions.png (4.9 KB)
Something similar is also available in print options.
How can I access this feature in aspose?
Workbook workbook = new Workbook("C:\\temp\\in.xslx");
workbook.save("C:\\temp\\out.pdf", com.aspose.cells.SaveFormat.PDF);
@martin.duerig
The code is the accurately right way to convert an excel file to one pdf that contains the entire workbook.
How can I setup the pdf export options like in the Excel screenshot below?
@martin.duerig,
Thanks for the screenshot.
You need to hide other sheets except active sheet before rendering to PDF. See the sample code for your requirements:
e.g.
Sample code:
Workbook wb = new Workbook("Book1.xlsx");
int activeSheetIndex = wb.getWorksheets().getActiveSheetIndex();
for(int i = 0; i < wb.getWorksheets().getCount(); i++)
{
if(activeSheetIndex != i)
{
wb.getWorksheets().get(i).setVisible(false);
}
}
wb.save("output.pdf");
Hope, this helps a bit.
@martin.duerig
To make things easier, we will support to specify sheets to output while exporting to pdf. Then you will be able to specify sheets to output at new API(e.g. PdfSaveOptions.SheetSet
) instead of setting visible/invisible for every sheet.
We have logged a ticket CELLSJAVA-44811, we will let you know if we have any progress.
@martin.duerig,
We are pleased to inform you that the ticket (logged earlier as " CELLSJAVA-44811") has been resolved now. The supported feature will be included in the next official release (Aspose.Cells v22.8) which is scheduled to be released in the second week of August 2022. You will also be notified when the next version is published.
@martin.duerig
In the coming release Aspose.Cells v22.8, the code will be:
Workbook wb = new Workbook("Book1.xlsx");
int activeSheetIndex = wb.getWorksheets().getActiveSheetIndex();
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setSheetSet(new SheetSet(new int[] {activeSheetIndex}));
wb.save("output.pdf", pdfSaveOptions);
The issues you have found earlier (filed as CELLSJAVA-44811) have been fixed in this update. This message was posted using Bugs notification tool by Peyton.Xu