HotXLS Delphi Excel Read Write Library / Component Developers Guide loslab Inc.

AfterTitle event

Occurs after the column title specified by FieldIndex is saved into the cell.

Description

You can use this event to apply conditional formatting to any header cell.

Syntax

TAfterTitle = procedure(Sender: TObject; Cell: IXLSRange; FieldIndex: Integer; Field: TField) of object;
Sender TObject. Specifies the TDataToXLS component that triggered the event.
Cell IXLSRange which represents the cell with the column title
FieldIndex Integer. The index of the field.
Field TField. An object that represents the field of dataset.

Example

This example sets the width of the column with index 2

procedure TForm1.DataToXLS1AfterTitle(Sender: TObject;
  Cell: IXLSRange; FieldIndex: Integer; Field: TField);
begin
  if FieldIndex = 2 then Cell.ColumnWidth := 30;
end;
This example shows how to change the text of column title

procedure TForm1.DataToXLS1AfterTitle(Sender: TObject;
  Cell: IXLSRange; FieldIndex: Integer; Field: TField);
begin
  Cell.Value := StringReplace(Cell.Value, '_', ' ', [rfReplaceAll]);
end;
Copyright©2014 loslab.com