Table of Contents

TExcelFile.MeasureString Method

Returns the size of a TRichString in points.

Syntax

Unit: FlexCel.Core

function TExcelFile.MeasureString(const text: TRichString; const cellFont: TFlxFont): TUISize; virtual; abstract;

Parameters

<-> Parameter Type Description
const text TRichString Rich string to measure.
const cellFont TFlxFont Font of the cell itself. This font might change later in the string.

Returns

The size in points

Examples

To measure the text in cell 1, 1, you can use the code:

procedure MeasureStringExample;
var
  xls: TXlsFile;
  size: TUISize;
const
  row = 1;
  col = 1;
begin
  xls := TXlsFile.Create('SomeFile.xlsx', true);
  try
    size := xls.MeasureString(xls.GetStringFromCell(row, col), xls.GetCellVisibleFormatDef(row, col).Font);
  finally
    xls.Free;
  end;
end;

See also