Reputation: 41
Is there any way to get row height of excel row in openxml? In my case, i use openxml 2.0 to generate excel table from .net datatable. For each datatable row, i define new row in excel by
row = new Row() { RowIndex = rowIndex };
after that i append cell to row
row.InsertBefore(newCell, refCell);
when finish generate excel table i want to get each row height to increase its. But it always null when use
Row row = ExcelHelper.GetRow(sheetData, Convert.ToUInt32(13));
DoubleValue a = row.Height;
Help me please! Thank!
Upvotes: 4
Views: 3605
Reputation: 14498
The Microsoft Excel Open XML Format rows only have the height
attribute when customHeight
attribute is set to true in XML, otherwise the row height is just the DefaultRowHeight
.
What you should do is first check if row.CustomHeight != null && row.CustomHeight.Value == true
and then you know it has a custom height and the Height
property won't be null.
In the other case you can get the default row height in the SheetFormatProperties.DefaultRowHeight
.
So to set the height of a row to your custom value, you need to change its CustomHeight
property to true, and Height
property to your custom row height.
Upvotes: 2