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

Free Support Forum - aspose.com

Converting XLSX to PDF- I end up with an empty file

Hello,
I’m trying to convert an XLSX file with simple content, no pivot tables or charts, and the PDF output contains none of the data which is in the original file.
The very peculiar thing is that if I open the problematic file with Excel and save it without modifying it in any way, the conversion works. Same if I modify it before saving it.
Other XLSX files work as well.

I’m using aspose-cells-8.7.2.jar but I’ve also tried using aspose-cells-17.5.jar and the results are the same.

This is the code I’m running :

Workbook workbook = new Workbook(inputDir + fileIn);
// Define PdfSaveOptions
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Set the compliance type
saveOptions.setCompliance(PdfCompliance.PDF_A_1_B);

// Save the PDF file
workbook.save(outputDir + fileOut, saveOptions);

I’ve tried work-arounds, like saving the file into another temporary XLSX file before using that file as the base for my PDF, but that didn’t work either.

I’ve attached the XLSX file as well as the invalid output PDF file. As mentioned above, manipulating the file in any way seems to “correct” it, so I would advise using it “as is”.

Can you find out what’s wrong and how I could solve the problem?

Thanks,

Johan

Hi,


Thanks for your posting and using Aspose.Cells.

We have tested your issue with the most recent version of Aspose.Cells and found the issue as per your description. We have logged this issue in our database for an investigation and for a fix.

This issue has been logged as

  • CELLSJAVA-42296 - Xlsx file is rendering as an empty Pdf

Hi,

Thanks for using Aspose.Cells.

We have looked into this issue further and found that the height of all rows inside your Excel file is zero but all the rows are auto height. This is the reason, when Microsoft Excel opens it, it automatically autofits rows' height as per their contents.

Please use the following code and you will get the correct Pdf with Aspose.Cells as well.

Java
Workbook wb = new Workbook(dirPath + "37072430_entrant.xlsx");

System.out.println(wb.getWorksheets().get(0).getCells().getRowHeight(80));

wb.getWorksheets().get(0).autoFitRows(true);

PdfSaveOptions saveOption = new PdfSaveOptions();
saveOption.setCompliance(PdfCompliance.PDF_A_1_B);

wb.save(dirPath + "outFile.pdf", saveOption);

Console Output
0