|
|
|||
Home Products Downloads Registered users Support Prices Order Primary Subscription |
|
||
TXLeport EventsThe pseudo-code below describes the algorithm of report generation:
procedure TxlAbstractReport.Report; var
Raised: boolean;
begin
i: integer;
Raised := true;
end;
try
try
finally
Connect;
except
if IsRefreshParams then
RefreshParams(True);
BeforeBuild;DoOnBeforeBuild; MacroProcessing(mtBefore, MacroBefore); Parse; Params.Build; for i := 0 to DataSources.Count - 1 do
if DataSources[i].RangeType = rtNoRange then begin
for i := 0 to DataSources.Count - 1 do
DataSources[i].Build;
end;
if DataSources[i].RangeType = rtRange then begin
for i := 0 to DataSources.Count - 1 do
DataSources[i].Build;
end;
if DataSources[i].RangeType = rtRangeRoot then begin
MacroProcessing(mtAfter, MacroAfter);
DataSources[i].BuildRoot;
end;
DoOnAfterBuild; OptionsProcessing; AfterBuild; Show;
on E: Exception do begin
end;
DoOnError(E, Raised);
end;
ErrorProcessing(E, Raised); if Raised then
raise E;
Disconnect;
end;
When the process starts (Connect), the XL Report instance gets pointers to all Excel interfaces, opens the template workbook, and adds the XLRpt_TempSheet worksheet and the XLRpt_Module VBA module. Starting from this moment the following interfaces are accessible in XL Report event handlers: IXLSApp, IWorkbooks, IWorkbook, ITempSheet, INames and so on. If the xroRefreshParams option is on, the Params collection is refreshed. Then the OnBeforeBuild event is triggered. Here you can initialize report parameters and/or perform any operations before the datasets will be open. Then the VBA macro specified in the MacroBefore property is invoked. Just before this the OnMacro event is triggered in order to allow you to pass macro parameters. Then the template is analyzed, report parameters are transferred, NoRange-datasets are transferred, and standalone Range-datasets are transferred. Then comes the turn of nested Range-datasets. After data transfer the MacroAfter VBA macro is invoked being preceded with the OnMacro event. The report and sheet options are processed, and the AfterBuild event is triggered. Excel is shown and its interfaces are freed (Disconnect). In case of any exception, the OnError event is triggered thus allowing you to process the exception. Every step described above is preceded with the OnProgress event. This is a standard event cycle for XL Report reporting. There are two events that can be triggered in following situations:
OnAfterBuildIs triggered after report generation.
property OnAfterBuild: TxlReportHandleEvent; type
TxlReportHandleEvent = procedure (Report: TxlReport) of object;
Use the event handler in order to carry out some additional actions after report generation. All Excel interfaces are accessible here. See also the OnBeforeBuild event. OnBeforeBuildIs triggered before report generation.
property OnBeforeBuild: TxlReportHandleEvent; type
TxlReportHandleEvent = procedure (Report: TxlReport) of object;
Use the event handler in order to carry out some additional actions after report generation. All Excel interfaces are accessible here. Many XL Report users prepare template workbooks in this event. See also the OnAfterBuild event. OnBeforeWorkbookSaveIs triggered in order to define the path and file name of the report workbook.
property OnBeforeWorkbookSave: TxlOnBeforeWorkbookSave; type
TxlOnBeforeWorkbookSave = procedure (Report: TxlReport;
var WorkbookName, WorkbookPath: string; Save: boolean) of object;
This event is triggered only if the xroAutoSave option is True. WorkbookName and WorkbookPath contain the path and file name of the report workbook. Both of them are not checked for existence. If the file exists an exception is fired. To save the report set Save = true, to prevent from saving set Save = false. OnBreakAllows canceling the report generation process.
property OnBreak: TxlOnBreak; type
TxlOnBreak = procedure (Report: TxlReport;
var IsBreak: boolean) of object;
Use this event in order to allow your users to cancel the report generation process. Set IsBreak to true if it is the case. Note. This event doesn't allow canceling long lasting VBA macros, in particular those specified in the MacroBefore and MacroAfter properties. OnErrorIs triggered in case of errors during report generation.
property OnError: TxlOnError; type
TxlOnError = procedure(Sender: TObject; E: Exception;
var Raised: boolean) of object;
Use this event in order to override the standard exception processing behavior of XL Report. If IsRaised = false all the raised exceptions will be suppressed in the Report method. Default: IsRaised = true. Exception type can be determined by use of the Exception parameter and Is operator. OnMacroIs triggered before calling VBA procedures supplied in MacroBefore and 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 if you need to pass some parameters to the VBA procedure. Assign the parameters' values to ArgXX in strict order, otherwise you get an exception. The DataSource parameter contains nil. If you make OnMacro event handler to be a common event handler for several instances of TxlReport class, you can use Tag property of the class and AMacroName - the name of the VBA procedure to be processed. OnProgressAccompanies every step of report generation.
property OnProgress: TxlOnProgress; type
TxlOnProgress = procedure (Report: TxlReport;
const Position, Max: integer) of object;
Use this event to visualize report generation. Max contains the number of report generation steps. Position contains the number of the current step. Because template options are analyzed in consecutive order, so Max can be changed during report generation. After report generation, this event is triggered again with Position and Max both equal to zero. Example:
procedure TfrmEvents1.xlReportProgress(Report: TObject; Position, Max: Integer); begin
pbReport.Min := 0;
end;
pbReport.Max := Max; pbReport.Position := Position; OnTargetBookSheetNameIs triggered in order to define the name of the worksheet being added to an existing workbook with the ReportTo method.
property OnTargetBookSheetName: TxlOnTargetBookSheetName; type
TxlOnTargetBookSheetName = procedure (Report: TxlReport;
ISheet: IxlWorksheet; ITargetWorkbook: IxlWorkbook;
var WorksheetName: string) of object; This event is triggered when the template worksheet is added to the target workbook . You can rename the worksheet by supplying the new name in the WorksheetName parameter. ISheet contains the interface to the worksheet, ITargetWorkbook contains the interface to the target workbook. |
Components
Developed forDelphi 4, 5, 6, 7 Excel version supportedMS Excel 97 (SR2)
[ Download it ] |