Issues converting Excels to PDF

@PeteLee,

You have two options to cope with it as we already posted in two replies:

@Amjad_Sahi @ahsaniqbalsidiqui

When I opened 20150126 - D1 Ownership.xlsx in excel it was only 28 pages. When I used excel to convert it to pdf (using the print command in excel for osx) It generated a pdf that was 28 pages. Why is aspose thinking it is that many millions of pages when excel renders it only as 28 pages?

Thanks

@PeteLee,

Well, generally Aspose.Cells follows MS Excel (for Windows) standards and specifications. When I used Ms Excel 2007/2013 and take the print preview of the sheet “Officers, Jurisdiction & Voting”, I see huge list of pages to be rendered, see the screenshot for your reference:

@PeteLee,
It seems that you are talking about first worksheet only which contains 28 pages when its print preview is taken in Excel for Windows and macOS. However if we take print preview of entire workbook it contains millions of pages as mentioned by @Amjad_Sahi above.

If you want to convert first worksheet to PDF only, you may try following code which converts the first sheet to PDF without any error:

	Workbook wb = new Workbook(path + "20150126 - D1 Ownership.xlsx");
	wb.getWorksheets().get(0).setVisible(true);
	for(int i = 1; i < wb.getWorksheets().getCount(); i++)
	{
		wb.getWorksheets().get(i).setVisible(false);
	}
	
    PdfSaveOptions opts = new PdfSaveOptions();
    wb.save(path + "FirstSheet.pdf", opts);

There are few other options as well to print the entire workbook without any error like using PdfSaveOptions.setPrintingPageType(1) OR PdfSaveOptions.setPrintingPageType(2). Here is the description of argument.

0:DEFAULT => Prints all pages.
1:IGNORE_BLANK => Don’t print the pages which the cells are blank.
2:IGNORE_STYLE => Don’t print the pages which cells only contain styles.

Here is the working example:

Workbook wb = new Workbook(path + "20150126 - D1 Ownership.xlsx");
PdfSaveOptions opts = new PdfSaveOptions();
opts.setPrintingPageType(2);//OR 1
wb.save(path + "output.pdf", opts);

Please give it a try and share the feedback.

that seems to have helped, thanks

@PeteLee,
You are welcome and feel free to write us back if you have any other query in this regard.

The issues you have found earlier (filed as CELLSJAVA-42991) have been fixed in Aspose.Cells for Java v19.9. This message was posted using BugNotificationTool from Downloads module by ahsaniqbalsidiqui