To extend report functionality, use:
Units containing custom Fore functions that can be used for data transformation. Signature of the specified unit can contain parameters.
Event handler is a Fore unit. An event handler enables the user to execute a specified operation each time the event occurs. For example, if an event handling unit is connected, one can: handle data input on the go, execute additional operations before and/or after any event.
Main purpose of connection of application units and event handlers:
Creating hyperlink triggers. If executing macros contained in the connected objects is required as their operations.
Creating formulas.
Event handling. To handle events, describe a class inherited from the ReportEvents class and redetermine methods that implement the required events.
One can set up handling of the report events that occur:
Before opening regular report.
Before and after changing the regular report active sheet.
Before and after calculating a data area (or relational data area), entire regular report or specific report sheet.
Before and after printing and exporting regular report.
Before and after saving changed values of data areas.
On changing value of regular report control.
Before saving regular report, and so on.
To work with report units and event handler, use the List of Units panel:
The following operations are available when working with report units and event handler:
Create event handler automatically
Connect an existing unit/event handler
Open unit/event handler in development environment
Remove unit/event handler from the list
To execute the example, create a unit. Add links to the Drawing, Express, Report, and Tab system assemblies.
Class EventsClass: ReportEvents
// Event that occurs after report sheet calculation
Public Sub OnAfterRecalcSheet(Sheet: IPrxSheet);
Var
Tab: ITabSheet;
Range: ITabRange;
Style: ITabCellStyle;
Begin
// Get report sheet table
Tab := Sheet As ITabSheet;
// Select cell range to be colored
Range := Tab.Cells(0, 0, 10, 5);
// Set formatting style for selected range
Style := Range.Style;
// Set green color of background for selected cell range
Style.BackgroundBrush := New GxSolidBrush.Create(GxColor.FromName("Green"));
End Sub OnAfterRecalcSheet(Sheet: IPrxSheet);
End Class EventsClass;
As a result, when the event occurs that follows regular report sheet calculation, background of the A0:F10 cell range is filled with green color.
See also: