We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error while saving the workbook

Hello,


While trying to get PDF of one of the sheets in the workbook, following exception is being thrown by Aspose:
Exception in thread “main” com.aspose.cells.CellsException: End of file reached.
at com.aspose.cells.bie.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.quark.qpp.office.service.TestAspose.getSheetPdf(TestAspose.java:150)
at com.quark.qpp.office.service.TestAspose.main(TestAspose.java:58)

However, I am able to save this sheet as PDF from MS Excel.

I have attached the Excel file being used for your reference and the PDF generated from MS Excel.

Following is the code snipped being used:

Workbook workbook = new Workbook(excelFilepath);
WorksheetCollection ws = workbook.getWorksheets();

for (int i = 0; i < ws.getCount(); i++) {
String sname = ws.get(i).getName();
if(!sheetName.equalsIgnoreCase(sname)){
ws.get(i).setVisible(false);
ws.get(i).getPageSetup().setTopMargin(0);
ws.get(i).getPageSetup().setBottomMargin(0);
ws.get(i).getPageSetup().setRightMargin(0);
ws.get(i).getPageSetup().setLeftMargin(0);
}
}

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);

workbook.save(excelFilepath+".pdf", pdfSaveOptions);

Thanks,
Neeraj

Hi Neeraj,


Thank you for providing your sample spreadsheet and code snippets.

We have evaluated your presented scenario while using the latest version of Aspose.Cells for Java 8.2.0.4, and we are able to replicate the said exception on our end. In order to further investigate the matter, and to provide a fix, we have logged a ticket with Id CELLSJAVA-40985 in our bug tracking system. Please spare us little time to properly analyze the problem cause, and to provide a fix (if applicable). In the meanwhile, we will keep you posted with updates in this regard.

The issues you have found earlier (filed as CELLSJAVA-40985) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Thanks. Its working fine now.


Thanks,
Neeraj

Hi,


Thanks for your feedback.

Good to know that it figures out your issue now. Feel free to write back if you have further comments or questions, we will be happy to assist you soon.

Thank you.