Class TcwXTab (unit Cwxtab)

Inherits from

TStringGrid

the declaration for the crosstab component

Constructors


constructor create(aOwner: TComponent);

constructor


Functions

destructor destroy;

destructor

procedure Execute;

*XTab custom routines*******************************************************} {execute

procedure SaveXTab(const sTable: string);

*I\O Routines*****************************************************************} {save crosstab as a table.

procedure UpdateXTab;

update XTAb

procedure DrawCell(Sender: TObject; Col, Row: Longint;Rect: TRect; State: TGridDrawState);

Protected declarations

*Paint Routines**************************************************************} {draw cell - this routine allows a cell to contain more than one line of text


procedure AddSummaries;

add summaries to the crosstab.

procedure DrawCellContents(const iRow, iCol: integer; eArray: TarrFloat);

draw cell contents - takes the array of floats and draws it into the cell as specified in the parameters

function FindBiggestStr(const sCell: string): integer;

return required pixels for string passed

function GetCellContents(const iRow, iCol: integer): TarrFloat;

get cell contents - returns the cell contents as an array of float.

procedure PopCols;

populate columns - read distinct values from column field into the grid's columns

procedure PopRows;

populate rows - read distinct values from row field into the grid's rows

procedure PopXTab;

populate cross-tab - the crux of the component.

procedure RunQuery(const sSQL: string);

run query - this is used by PopRows and PopCols to execute their SQL statements

procedure SetAgg(value: boolean);

set aggregate

procedure SetCells(value: boolean);

set cell heights and widths

procedure SetEmptyChar(value: TEmptyChar);

set empty char

procedure SetTable(value: TTable);

set Table

procedure SetXtab(value: TXObject);

set custom object which holds crosstab

Properties

property AggRowsCols : boolean


property AutoResize : boolean


property Crosstab : TXObject

Published declarations

property EmptyCellChar : TEmptyChar


property Table : TTable


Events

Variables

FCurrent : boolean;

Public declarations

FAgg : boolean;


FAutoResizeCells : boolean;


FEmptyChar : TEmptyChar;


FTable : TTable;


FXTab : TXObject;


Query1 : TQuery;

Private declarations


Constructors


constructor create(aOwner: TComponent);

constructor


Functions


destructor destroy;

destructor


procedure Execute;

*XTab custom routines*******************************************************} {execute


procedure SaveXTab(const sTable: string);

*I\O Routines*****************************************************************} {save crosstab as a table. Note that parameter is the table name, so should be no greater than eight characters


procedure UpdateXTab;

update XTAb


procedure DrawCell(Sender: TObject; Col, Row: Longint;Rect: TRect; State: TGridDrawState);

Protected declarations

*Paint Routines**************************************************************} {draw cell - this routine allows a cell to contain more than one line of text


procedure AddSummaries;

add summaries to the crosstab. Basically this routine will add a column and row, and populate both of these with the sum of the results in the respective cells.


procedure DrawCellContents(const iRow, iCol: integer; eArray: TarrFloat);

draw cell contents - takes the array of floats and draws it into the cell as specified in the parameters


function FindBiggestStr(const sCell: string): integer;

return required pixels for string passed


function GetCellContents(const iRow, iCol: integer): TarrFloat;

get cell contents - returns the cell contents as an array of float. Note that this routine is quite complex, since we have to read the values from the cell and, without knowing how many lines there are in the cell, split the text into the array


procedure PopCols;

populate columns - read distinct values from column field into the grid's columns


procedure PopRows;

populate rows - read distinct values from row field into the grid's rows


procedure PopXTab;

populate cross-tab - the crux of the component. Lots of code that basically concerns itself with iterating through the table, finding values in the row and column fields that match the current cell row\column headings, and then performing the math operation as specified by the developer


procedure RunQuery(const sSQL: string);

run query - this is used by PopRows and PopCols to execute their SQL statements


procedure SetAgg(value: boolean);

set aggregate


procedure SetCells(value: boolean);

set cell heights and widths


procedure SetEmptyChar(value: TEmptyChar);

set empty char


procedure SetTable(value: TTable);

set Table


procedure SetXtab(value: TXObject);

set custom object which holds crosstab


Properties


property AggRowsCols : boolean


property AutoResize : boolean


property Crosstab : TXObject

Published declarations


property EmptyCellChar : TEmptyChar


property Table : TTable


Events


Variables


FCurrent : boolean;

Public declarations


FAgg : boolean;


FAutoResizeCells : boolean;


FEmptyChar : TEmptyChar;


FTable : TTable;


FXTab : TXObject;


Query1 : TQuery;

Private declarations