|
|
|||
Home Products Downloads Registered users Support Prices Order Primary Subscription |
|
||
TxlDataSource EventsThe pseudo-code below describes the algorithm of data transfer for a given DataSource.
procedure TxlAbstractDataSource.Build; begin
if Enabled then
end;
try
Connect;
finally
DoOnBeforeDataTransfer; MacroProcessing(mtBefore, MacroBefore); if Assigned(DataSet) then begin
// data from DataSet
endif xrgoAutoOpen in Options then
DataSet.Open;
else begin
// unbound data
end;DoOnGetDataSourceInfo; for i := 1 to FieldsCount do
DoOnGetFieldInfo;
Parse; if Assigned(DataSet) then
// data from DataSet
else begin
PutData
// unbound data
end;Eof := false; while not Eof do
GetRecord(RecBuf, Eof);
MacroProcessing(mtAfter, MacroAfter); DoOnAfterDataTransfer; OptionsProcessing;
if Assigned(DataSet) and (xrgoAutoClose in Options) then
end;
DataSet.Close;
Disconnect;
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). OnAfterDataTransferIs 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. OnBeforeDataTransferIs 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. OnGetDataSourceInfoAllows 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. OnGetFieldInfoAllows 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);
OnGetRecordIs 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; OnMacroIs 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. |
Components
Developed forDelphi 4, 5, 6, 7 Excel version supportedMS Excel 97 (SR2)
[ Download it ] |