NativeExcel suite v1.x

AfterHeaderCell event

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

Description

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

Syntax

TAfterHeaderCell = procedure(Sender: TObject; Cell: IXLSRange; FieldIndex: integer; Field: TField) of object;
SenderTObject. Specifies the TDataset2Excel component that triggered the event.
CellIXLSRange which represents the cell with the column title
FieldIndexInteger. The index of the field.
FieldTField. An object that represents the field of dataset.

Example

This example sets the width of the column with index 2
procedure TForm1.Dataset2Excel1AfterHeaderCell(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.Dataset2Excel1AfterHeaderCell(Sender: TObject;
  Cell: IXLSRange; FieldIndex: Integer; Field: TField);
begin
  Cell.Value := StringReplace(Cell.Value, '_', ' ', [rfReplaceAll]);
end;
Copyright © NikaSoft 2004-2012