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

Free Support Forum - aspose.com

AutoFitRows and merged column

See attached sample: a cell is merged over three columns, and the text contains a linebreak.
AsposeCellsTest.zip (4.8 KB)
I call “AutoSizeRows” with “AutoFitterOptions.AutoFitMergedCellsType” (https://docs.aspose.com/cells/net/autofit-rows-for-merged-cells/. The property “Style.IsTextWrapped” is also set to “true”.
But in the resulting document, the row still has the default height.

The same happens if the cell content has no linebreak, but is long enough to wrap.

When a cell spans multiple rows, the row height is calculated properly.

Attached sample is a .NET5 project, but the issue happens for us in a .NET 4.8 application.

Best regards


It seems that Aspose.Cells correctly calculates the height (“25.5”), but Excel breaks it somehow.

I opened the file with Excel, set the row height to “25.5” and saved again, and compared the xml content.

This is the relevant part of “sheet1.xml” in the original doc:

    <row r="2" spans="2:2" ht="25.5">
      <c r="B2" s="1" t="s">

After setting the row height in Excel and saving again, this is the result:

    <row r="2" spans="2:4" ht="25.5" customHeight="1" x14ac:dyDescent="0.2">
      <c r="B2" s="2" t="s">
      <c r="C2" s="1"/>
      <c r="D2" s="1"/>

The attribute “customHeight=1” seems to make the difference - I edited the xml file create by Aspose and added this snippet, and the result looked fine in Excel.


We already fixed similar issue recently. I tested using your sample code and it works fine with latest fix/version. Could you please try our latest fix/version Aspose.Cells for .NET v21.12.6 (attached):
Aspose.Cells21.12.6 For .Net2_AuthenticodeSigned.Zip (5.6 MB)
Aspose.Cells21.12.6 For .Net4.0.Zip (5.6 MB)
Aspose.Cells21.12.6 For .NetStandard20.Zip (5.6 MB)

Let us know if you still find any issue.

I am used to hyperspeed bugfixes a few days after my bugreport, but it scares me a bit that you now start fixing bugs before I discover them ;-).

Thanks, my sample works now, and I see that you set the “customHeight” attribute.

Awaiting the next release…


It is nice to know that your issue is resolved by using the new fix.

We are scheduled to publish the next official release around mid January, 2022.