Microsoft Excel reporting and 
 data analyzing with practically no coding. 
 .Net, ActiveX, and VCL versions. 
 www.AfalinaSoft.com  

Home    Products    Downloads    Registered users    Support    Prices    Order    Primary Subscription

 

MS Office COM Add-ins. Microsoft Excel reporting 
 and data analyzing


TxlDataSource Events - AfalinaSoft XL Report Programmer's Reference

<< Previous

Table of contents

Next >>


TxlDataSource Events


The pseudo-code below describes the algorithm of data transfer for a given DataSource.

procedure TxlAbstractDataSource.Build;
begin
if Enabled then
try
Connect;
DoOnBeforeDataTransfer;
MacroProcessing(mtBefore, MacroBefore);
if Assigned(DataSet) then begin
// data from DataSet
if xrgoAutoOpen in Options then
DataSet.Open;
end
else begin
// unbound data
DoOnGetDataSourceInfo;
for i := 1 to FieldsCount do
DoOnGetFieldInfo;
end;
Parse;
if Assigned(DataSet) then
// data from DataSet
PutData
else begin
// unbound data
Eof := false;
while not Eof do
GetRecord(RecBuf, Eof);
end;
MacroProcessing(mtAfter, MacroAfter);
DoOnAfterDataTransfer;
OptionsProcessing;
finally
if Assigned(DataSet) and (xrgoAutoClose in Options) then
DataSet.Close;
Disconnect;
end;
end;

When the process starts (Connect), pointers to all Excel interfaces are initialized. Then the OnBeforeDataTransfer event is triggered and the macro specified in the MacroBefore property is invoked. If the dataset isn't open and xrgoAutoOpen is on, the dataset is open. If the dataset isn't assigned, it is assumed that arbitrary data should be transferred to the report and the OnGetDataSourceInfo event is triggered. You use this event in order to define the structure of data and the number of fields. Each field causes triggering of the OnGetFieldInfo event where you supply XL Report with the field type. The template range is parsed and data are transferred In case of arbitrary data, each "record" is accompanied with triggering of the OnGetRecord event. The macro specified in the MacroBefore property is invoked and the OnAfterDataTransfer event is triggered. If the xrgoAutoClose option is on, the dataset is closed. All Excel interfaces are freed (Disconnect).

OnAfterDataTransfer

Is triggered after data transfer.

property OnAfterDataTransfer: TxlDataTransferHandleEvent;
type
TxlDataTransferHandleEvent = procedure (DataSource: TxlDataSource) of object;

Use this event to carry out any additional actions after data transfer. This also is the place where you can use the Excel interfaces described in corresponding sections of this Help. See also OnBeforeDataTransfer.

OnBeforeDataTransfer

Is triggered before data transfer.

property OnBeforeDataTransfer: TxlDataTransferHandleEvent;
type
TxlDataTransferHandleEvent = procedure (DataSource: TxlDataSource) of object;

Use this event to carry out any additional actions before data transfer. This also is the place where you can use the Excel interfaces described in corresponding sections of this Help. See also OnAfterDataTransfer.

OnGetDataSourceInfo

Allows describing the structure of arbitrary data.

property OnGetDataSourceInfo: TxlGetDataSourceInfo;
type
TxlGetDataSourceInfo = procedure (DataSource: TxlDataSource;
var FieldCount: integer) of object;

XL Report operates on tabular data so you have to define your data structure (even if you work with single record). If the DataSet property of the DataSources collection item is empty, this event is triggered. You define the number of fields in your by passing it in the FieldCount parameter. This causes triggering the OnGetFieldInfo event FieldCount times.

OnGetFieldInfo

Allows defining the field name and type for arbitrary data.

property OnGetFieldInfo: TxlGetFieldInfo;
type
TxlGetFieldInfo = procedure (DataSource: TxlDataSource;
const FieldIndex: integer;
var FieldName: string; var FieldType: TxlDataType) of object;

XL Report operates on tabular data so you have to define your data structure (even if you work with single record). If the DataSet property of the DataSources collection item is empty, this event is triggered. You define the number of fields in your by passing it in the FieldCount parameter. This causes triggering the OnGetFieldInfo event FieldCount times. XL Report field types are:

type
TxlDataType = (xdNotSupported, xdInteger, xdBoolean, xdFloat,
xdDateTime, xdString);

OnGetRecord

Is triggered for every "record" of an arbitrary data dataset.

property OnGetRecord: TxlGetRecord;
type
TxlGetRecord = procedure (DataSource: TxlDataSource;
const RecNo: integer;
var Values: OLEVariant; var EOF: boolean) of object;

OnMacro

Is triggered before invoking the VBA procedure specified in MacroBefore or MacroAfter properties.

property OnMacro: TxlOnMacro;
type
TxlOnMacro = procedure (Report: TxlReport; DataSource: TxlDataSource;
const AMacroType: TxlMacroType; const AMacroName: string;
var Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9,
Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18,
Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27,
Arg28, Arg29, Arg30: OLEVariant) of object;

Use this event in order to pass parameters to the VBA procedure. Assign the parameters' values to ArgXX in strict order, otherwise you will get an exception. DataSource points to the instance of TxlDataSource corresponding to this event. If you make OnMacro event handler to be a common event handler for several instances of TxlDataSource class, you can use the Tag property of the class and AMacroName - the name of the VBA procedure to be invoked.

<< Previous

Table of contents

Next >>



Components

xlReport xlReport

Developed for

Delphi 4, 5, 6, 7
C++Builder 4, 5, 6

Excel version supported

MS Excel 97 (SR2)
MS Excel 2000
MS Excel 2002 (XP)
MS Excel 2003



[ Download it ]
[ Order now ]



We are Borland 
 technology partner

Copyright © 1999-2006
All right reserved.
Privacy Policy

Write to WebMaster

Page Top
Add-in Express - Visual tool for Office customization