Message-ID: <85869421.8911.1711667862030.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8910_473915792.1711667862030" ------=_Part_8910_473915792.1711667862030 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Workbook.GetTextHeight(String, Font, Double)

Workbook.GetTextHeight(String, Font, Double)

D= escription

=20

Returns the minimum height required to fit the given text string using t= he given font.

=20
C#
=20
 public double GetTextHeight(System.String text, Font font, double desiredW=
idth)
=20
=20
vb.net
=20
Public Function GetTextHeight(ByVal text As String, ByVal font As Font, ByV=
al desiredWidth As Double) As Double
=20
=20

Parameters=

=20
text
The te= xt string whose height will be calculated.=20
font
The fo= nt that will be used to format the text.=20
desiredW= idth
The width, in character units, of the cell or area into which the= text will be inserted.=20

Returns

= The minimum height, in character units, required to accommodate the given t= ext string.=20

Remarks

= 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 hei= ght of each row to accommodate the total minimum height of the text.=20

Examples=20
C#
=20

//--- What is the width of column C?
ColumnProperties colProps =3D worksheet.GetColumnProperties(2);

//--- How tall will the data be?
double requiredHeight =3D wb.GetTextHeight(longTextString,
                                         colProps.Style.Font,
                                         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 =3D (int) Math.Round((requiredHeight / 409) + 0.5);

//--- Evenly distribute the required height across all of the rows.
worksheet.Cells[2, 2].Value =3D longTextString;
Area a =3D worksheet.CreateArea(2, 2, numRows, 1);
a.MergeCells();
a.AllRowsHeight =3D (requiredHeight / numRows);
=20
=20
vb.net
=20

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

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

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

------=_Part_8910_473915792.1711667862030--