Hi- I have simple Aspose.Cells code where I’m saving a workbook to a pdf using the SaveFormat.Pdf and the spacing doesn’t match the Excel file. In the attached file, you’ll see that the workbook row 20 looks fine in Excel. But when saved to a pdf the row height changed and it looks like it’s double in the pdf.
TSRSummary_Report_January 1 2023 Grant (Test).zip (65.9 KB)
Thanks for the template Excel file and output PDF file.
I reviewed your scenario using the provided template Excel file and noticed that some rows are set to auto height. This means that when you open the file in MS Excel manually, those rows are automatically adjusted to fit their content precisely (e.g., row 20). While MS Excel handles this automatically, in Aspose.Cells, you would need to configure this manually in your code. See the following sample code for your reference, it works fine as I tested.
e.g.,
Sample code:
Workbook workbook = new Aspose.Cells.Workbook("e:\\test2\\TSRSummary_Report_January 1 2023 Grant (Test).xlsm");
//auto-fit those rows in the first worksheet only which are set as auto height
workbook.Worksheets[0].AutoFitRows(true);
workbook.Save("e:\\test2\\out1.pdf");
Please see the below line of code in particular, so you may add similar line to your code snippet to make it work.
workbook.Worksheets[0].AutoFitRows(true);
Please find attached the output PDF which is fine tuned as I tested using the (above) sample code.
out1.pdf (50.0 KB)
Please let us know if you still have any issue or comments.