"AutoFitRows" does not work in combination with merged cells and borders

See attached sample: I create a table with merged ranges and cell borders. One cell (with blue background) has a long wrapped text, and it spans two cols.
AutoFitRows does not work for this cell.
AsposeCellsAutoFit.zip (4.5 KB)

I use the “AutoFitRows” approach which handles merged ranges:

  AutoFitterOptions afo = new AutoFitterOptions();
  afo.AutoFitMergedCellsType = AutoFitMergedCellsType.LastLine;
  _workSheet.AutoFitRows(1, 1, afo);

But it does not work here.

This seems to be related to borders - if I remove them (set variable “bolSetBorders” to false in the sample), the behavior is as expected.

Do you have any ideas? Is it an error in my sample or a bug?

Best regards

Wolfgang

@wknauf,

We reproduced the issue as you mentioned by using your sample. We found “AutoFitRows” does not work in combination with merged cells and borders.

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-53035

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.

@wknauf,

This is to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v23.4) that we plan to release in the first half of April 2023. You will be notified when the next version is released.

Great, many thanks!

Wolfgang

@wknauf,

You are welcome.

I can confirm that this works with 23.4.

But now the autosized row seems to be higher than necessary. There might fit another line of text in the empty space :
excel.png (3.5 KB)

Is this something that can be improved?

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

I tested your scenario/case with latest version (v23.4) and noticed that auto-fit rows operation is extending height generously a bit with merged cells. I think you have to live with it for now. We might enhance it further in future versions (if possible).

I have to admit: in our real sample, the height fits perfectly. Hopefully, this will be a rare problem and no customer will notice it ;-).

@wknauf,

Good to know that in your original sample, it works fine. Feel free to contact us any time if you have further queries or issue, we will be happy to assist you soon.

@wknauf

Please check the codes:
cellCurrent.Value = “Fortune\n08:00–14:00\nAbbau\n08:00 - 13:00 Abbau Büt. & Bel.\n13:00 Verladen \n”;
The value of the cells ends with NewLine , we can not ingore it , so there is an empty row.
If you do not want that line, please change your codes to remove end Newline.

Thanks, you are right. This was user input ;-). Sorry, I should have noticed this myself!

@wknauf,
You are welcome. If you have any questions, please feel free to contact us.