XLSX to PDF: Content is lost

Hello!

I am converting XLSX to PDF, and i detected a problem with the attached file. xlsx2PdfContentLost.zip (52.7 KB)

If you compare the XLSX and the resulting PDF, you can see, that content from the first row and the first column ist not present in the PDF.

Kind regards!

@dvtdaten,

We have evaluated your issue and found there is specific printable area (i.e., B1:O25) set for the sheet (in MS Excel, open Page Setup dialog and check Print area which does not cover all the data range of the sheet). That’s why when you render either by MS Excel or via Aspose.Cells, it just renders specific area only and misses certain column(s) or data of the sheet (mind you, both Aspose.Cells and MS Excel renders to PDF based on what is shown in the print preview of the sheet). To fix the issue, please either remove the printable area manually (in MS Excel) to re-save the file or set/remove the area to cover the whole range before rendering to PDF. You can do that either by using MS Excel or via Aspose.Cells in code. See the sample lines of code for your reference.
e.g.
Sample code:

Workbook workbook = new Workbook(sourceFile);
//......
//your code goes here.
//.......
Worksheet sheet = workbook.getWorksheets().get(0);
// remove the printable area
sheet.getPageSetup().setPrintArea("");
workbook.save("out1.pdf", SaveFormat.PDF);

Let us know if you still find any issue.

Thank you a lot, removing the printable area fixes the problem.
As I have to convert lots of xlsx-files from unknown sources, I guess I have to remove the printable area for all worksheets.
Or is there another way to ignore the printing area during conversion?

Yes, you may use the proposed workaround (as suggested) to remove printable areas (if any) set of the worksheets in the workbook.

But I notice a remarkable difference between MS Excel and Aspose in the processing of those printable areas:

  • Aspose.Cells loses the text of the first line, because it is in the first column, which is not in the printable area.
  • MS Excel prints the text of the first line, although it is not in the printable area.

@dvtdaten,

Yes, we noticed and technically MS Excel should not render the text in the first line (first column). Anyways, you should remove the printable areas of the sheets in the workbook before rendering to PDF file format. This will ensure that everything will be rendered in the output PDF.

I get your point, but I can also see why MS Excel handles it differently.
But anyway, I removed the printable area, so this problem is fixed. Thank you for your quick support!

@dvtdaten,

You are welcome.