Excel to PDF - Cropped cells when converting to PDF in .NET

Hello,

the cells height will not adjust when we convert this Excel file to PDF, resulting in a PDF with cropped cropped text in the cells. The Excel file was created by copying multiline text of an existing Excel file and pasting it into a new one.

How can we prevent this from happening?

I attached the code, the original Excel file as well as the resulting PDF file.

Kind regards,
Bea
FB486_CroppedExcelTableCells.zip (43.0 KB)

@bea.grosse-venhaus,
I have tested the issue with the latest version Aspose.Cells for .NET 21.8 in Windows environment but could not observe the cropped cells issue. Could you please share which version are you using and also share your environment details? If you are not using the latest version, please try the scenario with the latest version and share your feedback.

Here is the output generated by your program here:
output.pdf.zip (20.9 KB)

Hello @ahsaniqbalsidiqui,

thank you for the fast reply.
We use .Net 4.7.2 in a SharePoint 2019 environment and Aspose.Cells for .Net 21.5.

I converted our file with your online converter with the same (cropped) result

Kind regards,
Bea

@bea.grosse-venhaus,

Online coverter might be using older Aspose.Cells for .NET APIs. So, as recommend by @ahsaniqbalsidiqui, please try using our latest version/fix (Aspose.Cells for .NET 21.8).

@bea.grosse-venhaus

Please add the code worksheet.AutoFitRows(true); , it will be OK.

Code:

...
foreach (Worksheet worksheet in workbook.Worksheets)
{
    worksheet.PageSetup.PrintArea = "";
    worksheet.PageSetup.Orientation = PageOrientationType.Portrait;
    worksheet.AutoFitRows(true);
}
...

Hello @Peyton.Xu,

thank you for the hint! That worked!

Kind regards,
Bea

@bea.grosse-venhaus,

Good to know that the suggested code segment works for your needs. In the event of further queries or issue, feel free to write us back.