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

Free Support Forum - aspose.com

How to set row height Dynamically?

Would you please tell me how to set row height dynamically? I have used below code but row height not increasing dynamically.Please help me.

cell B15 row height increasing dynamically
but cell B5 row height not increasing dynamically due to merged rows.

Workbook workbook = new Workbook();
//Get the first (default) worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Get the cells in the sheet.
Cells cells = sheet.Cells;
//Merging two cells (B5:D6)into a single cell(B5).
cells.Merge(4, 1, 2, 3);
//Put some value into the merged cell.
cells[“B5”].PutValue(“test test test ajflk ladjfadsflend!asdfasdfa !asdfasdfasd!asdfasdf!”);
//Align the text as Center aligned.
cells[“B5”].Style.HorizontalAlignment = TextAlignmentType.Center;
//Set wrapping text.
cells[“B5”].Style.IsTextWrapped = true;
sheet.AutoFitRow(4, 5, 1, 3);

sheet.Cells.SetColumnWidth(1, 10);
cells[“B15”].PutValue(“test test test ajflk ladjfadsflend!asdfasdfa !asdfasdfasd!asdfasdf!”);
cells[“B15”].Style.IsTextWrapped = true;

//Save the file.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> Hi,

Thank you for considering Aspose.

Well, I think MS Excel does not autofit the row height for the row having merged cells either. As I tried it manually using MS Excel and it does not autofit the row if it has merged cells. You may use Cells.SetRowHeight(int Row,double Height) method to manually set the row height for the row having merged cells.

Thank You & Best Regards,