RadSpreadProcessing - AutoFitHeight with merged cell

1 Answer 68 Views
SpreadProcessing
Loy
Top achievements
Rank 1
Loy asked on 14 Jul 2023, 04:24 PM

I do notice that the AutoFitHeight works fine when I'm dealing with only a single row without any merged cells.

I have a situation where I have a merged cell which is the combination of cells from the same row (i.e. B2-B5).  When trying to use AutoFitHeight, there is no change to the row height.

Is there anything I could do? 

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 18 Jul 2023, 09:48 AM

Hello Loy,

When calling the AutoFitHeight method on a row that contains merged and wrapped cells the RowHeight value is set to default instead of calculating the row height according to its content. In that case, the row size must be manually set. In order to measure the cell content and obtain the cell content measurements you can check the exposed by the LayoutHelper class methods.

Example:

Size cellContentSize = LayoutHelper.CalculateCellContentSize(worksheet, rowIndex, columnIndex);
worksheet.Rows[0].SetHeight(new RowHeight(cellContentSize.Height, true));

Hope this helps.

Regards,
Yoan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
SpreadProcessing
Asked by
Loy
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or