NativeExcel suite v2.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

TDBGridAfterHeaderCell = procedure(Sender: TObject; Cell: IXLSRange; ColumnIndex: integer; Column: TColumn) of object;
SenderTObject. Specifies the TDBGrid2Excel component that triggered the event.
CellIXLSRange which represents the cell with the column title
ColumnIndexInteger. The index of the column.
ColumnTColumn. An object that represents the column.

Example

This example sets the width of the column with index 2
procedure TForm1.DBGrid2Excel1AfterHeaderCell(Sender: TObject;
  Cell: IXLSRange; ColumnIndex: Integer; Column: TColumn);
begin
  if ColumnIndex = 2 then Cell.ColumnWidth := 30;
end;
This example shows how to change the text of column title
procedure TForm1.DBGrid2Excel1AfterHeaderCell(Sender: TObject;
  Cell: IXLSRange; ColumnIndex: Integer; Column: TColumn);
begin
  Cell.Value := StringReplace(Cell.Value, '_', ' ', [rfReplaceAll]);
end;
Copyright © NikaSoft 2004-2012