Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: spelling errors and indentation

...

Returns

The minimum height, in character units, required to accomodate accommodate the given text string.

Remarks

Themaximum The maximum height of any one row is 409 units, so if the height return is greater than 409, you must merge cells across multiple rows and set the height of each row to accomodate accommodate the total minimum height of the text.

Example
Code Block
csharp
csharp
titleC#

          //--- 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);
        
Code Block
vb.net
vb.net
titlevb.net

          '--- What is the width of column C?
          Dim colProps As ColumnProperties = worksheet.GetColumnProperties(2)

          '--- How tall will the data be?
Dim requiredHeight As Double = wb.GetTextHeight(longTextString, _
   Dim requiredHeight As Double = _                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.
          Dim numRows As Integer = Math.Round((requiredHeight / 409) + 0.5)

          '--- Evenly distribute the required height across all of the rows.
          worksheet.Cells(2, 2).Value = longTextString
          Dim a As Area = worksheet.CreateArea(2, 2, numRows, 1)
          a.MergeCells()
          a.AllRowsHeight = (requiredHeight / numRows)