//--- What is the width of column C?
ColumnProperties colProps = worksheet.GetColumnProperties(2);
//--- How tall will the data be?
double requiredHeight = wb.GetTextHeight(longTextString,
double requiredHeight = wb.GetTextHeight(longTextString, colProps.Style.Font,
colProps.WidthInChars); colProps.WidthInChars);
//--- Will we need multiple rows to display all of the data?
//--- Can not exceed 409 character units in height per row.
int numRows = (int) Math.Round((requiredHeight / 409) + 0.5);
//--- Evenly distribute the required height across all of the rows.
worksheet.Cells[2, 2].Value = longTextString;
Area a = worksheet.CreateArea(2, 2, numRows, 1);
a.MergeCells();
a.AllRowsHeight = (requiredHeight / numRows);
|