Aspose.Cells AutoFitRows is not accurate

Description

I want to convert a XLSX file with overflow text cell to PDF format, and I found that the cell with overflow text was not full display in PDF, so I think I need to change all rows’s height to max of their text value, but sheet.AutoFitRows() get an inaccurate result.

Env

  • Aspose.Cells for .NET 23.4
  • Windows 10

Code

	var doc = new Aspose.Cells.Workbook(@"C:\Users\Administrator\Desktop\test\1.xlsx");
	doc.Worksheets.ToList().ForEach(k =>
	{
		k.AutoFitRows();
	});
	doc.Save(@"C:\Users\Administrator\Desktop\test\1.pdf", Aspose.Cells.SaveFormat.Pdf);

Files

test.zip (17.8 KB)

Preview

20230426090048.png (9.2 KB)
20230426090112.png (95.0 KB)

@xucongli1989
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-53259

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@xucongli1989

If you manually autofit the row in Excel, then manually save to pdf. You will get the same result as our generated pdf.

In a word, the printview may be different with the normal view as you see in Excel.

@xucongli1989
To meet your requirement that AutoFitRows is just for rendering to pdf, we will add a new API for it. e.g. AutoFitterOptions.ForRendering.
Code will be something like:

Workbook wb = new Workbook("1.xlsx");

AutoFitterOptions autoFitterOptions = new AutoFitterOptions();

//autofit rows for rendering.
autoFitterOptions.ForRendering = true;

foreach (Worksheet sheet in wb.Worksheets)
{
    sheet.AutoFitRows(autoFitterOptions);
}

wb.Save("output.pdf");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-53267

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@xucongli1989,

We are pleased to inform you that your issue (“CELLSNET-53267”) has been resolved. This enhancement/fix will be included in our upcoming Aspose.Cells v23.5, scheduled for release in the first half of May 2023. You will be notified when the next version is published.

The issues you have found earlier (filed as CELLSNET-53267) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi