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

AfterTitle event

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

Description

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

Syntax

TDBGridAfterTitle = procedure(Sender: TObject; Cell: IXLSRange; ColumnIndex: Integer; Column: TColumn) of object;
Sender TObject. Specifies the TGridToXLS component that triggered the event.
Cell IXLSRange which represents the cell with the column title
ColumnIndex Integer. The index of the column.
Column TColumn. An object that represents the column.

Example

This example set the width of the column with index 3
procedure TForm1.GridToXLS1AfterTitle(Sender: TObject;
  Cell: IXLSRange; ColumnIndex: Integer; Column: TColumn);
begin
  if ColumnIndex = 3 then Cell.ColumnWidth := 30;
end;
This example show how to change the text of column title
procedure TForm1.GridToXLS1AfterTitle(Sender: TObject;
  Cell: IXLSRange; ColumnIndex: Integer; Column: TColumn);
begin
  Cell.Value := StringReplace(Cell.Value, '_', ' ', [rfReplaceAll]);
end;
Copyright©2014 loslab.com