TfrxReport

This component is the main one. One TfrxReport component contains one report.

In design-time, double-clicking the component calls the report designer. The component has all necessary properties and methods for report loading and saving, design and viewing. Let us examine the TfrxReport methods:

procedure Clear;

Clears a report.

function LoadFromFile( const FileName: String ; ExceptionIfNotFound:

Boolean = False): Boolean;

Loads a report from a file with given name. If the second parameter is equal to “True,” and the file was not found, an exception will be generated. It returns “True,” if the file is loaded successfully.

procedure LoadFromStream(Stream: TStream);

Loads a report from the stream.

procedure SaveToFile( const FileName: String );

Saves a report to a file with given name.

procedure SaveToStream(Stream: TStream);

Saves a report to the stream.

procedure DesignReport;

Calls the report designer. The designer should be included into your project (to perform this, it is enough to either use the “TfrxDesigner” component, or include the “frxDesgn” unit into the “Uses” list).

procedure ShowReport(ClearLastReport: Boolean = True);

Starts a report and displays a result in the preview window. If the “ClearLastReport” parameter is equal to “False,” then a report will be added to the previously constructed one, otherwise the previously constructed report is cleared (by default).

function PrepareReport(ClearLastReport: Boolean = True): Boolean;

Starts a report without a preview window. The parameter assignment is the same as in the “ShowReport” method. If a report is constructed successfully, this function returns “True.”

procedure ShowPreparedReport;

Displays the report, which was previously built via the “PrepareReport” call.

procedure Print;

Prints a report.

procedure Export(Filter: TfrxCustomExportFilter);

Exports a report using the specified export filter.

Since the following methods are service ones, in most cases you would not need to use them. They may be useful for FastReport functionality enhancement, for example, when writing custom report components.

function Calc( const Expr: String ): Variant;

Calculates the “Expr” expression and returns the result.

function GetAlias(DataSet: TfrxDataSet): String ;

Returns an alias for the given data set. Dataset should be included in the TfrxReport.Datasets.

function GetDataset( const Alias: String ): TfrxDataset;

Returns the data set on its alias name. Dataset should be included in the TfrxReport.Datasets.

procedure DoNotifyEvent(Obj: TObject; const EventName: String );

Executes the “EventName” event handler of the “TfrxNotifyEvent” type, connected to the  “Obj” object.

procedure DoParamEvent( const EventName: String ; var Params: Variant);

Executes the “EventName” event handler of the voluntary type with parameters.

procedure GetDatasetAndField( const ComplexName: String ; var Dataset:

TfrxDataset; var Field: String );

Parses the “ComplexName” complex name of the DataSet.”Field” type, returning the reference to the dataset, and the field.

procedure GetDataSetList(List: TStrings; OnlyDB: Boolean = False);

Returns the list of the data sets available in the report in the “List” parameter. The second parameter specifies whether it is necessary to return only the data sets, connected with DB.

function GetIniFile : TCustomIniFile ;

Returns the ini-file instance that stores all the designer settings. It may be either ini-file or registry, depending on IniFile property value.

procedure AddFunction( const FuncName: String ; const Category: String =

''; const Description: String = '');

Adds a user function to the list of the functions available in the report. See more in the “The functions’ list extension” chapter.

The TfrxReport component has the following properties:

property EngineOptions: TfrxEngineOptions;

A set of properties related to the FastReport engine.

property IniFile: String ;

A file name or a name of the registry key for storing the FastReport environment settings.

property Preview: TfrxCustomPreview;

A link to the “TfrxPreview” component, in which the finished report should be displayed.

If this property is blank, a report is displayed in the standard preview window. See the “Custom preview windows creating” chapter.

property PreviewOptions: TfrxPreviewOptions;

A set of properties, relating to the report preview.

property PrintOptions: TfrxPrintOptions;

A set of properties, which relate to the report printing.

property ReportOptions: TfrxReportOptions;

Defines a set of properties relating to the report.

property ScriptLanguage: String ;

Script language used in a report.

property ScriptText: TStrings;

Script text.

property AllObjects: TList readonly;

The list of all objects, the report contains (including pages).

property DataSets: TfrxReportDataSets readonly;

The list of data sets available for the report.

property Designer: TfrxCustomDesigner readonly;

A link to the report designer (actual when the designer is enabled).

property Engine: TfrxCustomEngine readonly;

A link to the report engine. It is useful in cases when it is necessary to operate a process of the report construction from a code.

property Errors: TStrings readonly;

The list of errors, occurring during one or another operation.

property FileName: String ;

Defines a report file name; it is displayed in the designer.

property PreviewPages: TfrxCustomPreviewPages readonly;

Defines a link to the pages of a finished report. It is used in all operations, which are connected with a finished report (printing, saving, export, etc.).

property Pages[Index: Integer]: TfrxPage readonly;

The list of report pages. The pages of the “dialogue form” type are also included in this list.

property PagesCount: Integer readonly;

Number of pages in a report template.

property Script: TfsScript readonly;

The “TfsScript” component, linked to the report. By using this link, you can add your variables, classes, functions, which can be used in a report script in the future. See more in the FastScript developer’s manual.

property Style: TfrxStyle;

Report style. See more about operating with styles in the corresponding chapter.

property Variables: TfrxVariables readonly;

The list of report variables. See more about operating with variables in the corresponding chapter.

A set of properties related to the FastReport engine:

TfrxEngineOptions = class (TPersistent)

published

property ConvertNulls: Boolean default True;

Converts the “Null” value of the DB field into “0,” “False,” or empty string, depending on the field type.

property DoublePass: Boolean default False;

Makes a report a two-pass one.

property MaxMemSize: Integer default 10;

The maximum size of memory in Mbytes, allocated to the report pages’ cache. It becomes useful in cases when the “UseFileCashe” property is equal to “True.” If a report begins to occupy more memory during construction, caching of the constructed report pages into a temporary file is performed. This property is inexact and allows only approximate determination of the memory limit.

property PrintIfEmpty: Boolean default True;

Defines, whether it is necessary to print a blank report (one which containing no data lines).

property SilentMode: Boolean default False;

“Silent” mode. Thus all messages about errors are stored in the “TfrxReport.Errors” property, without displaying any messages on the screen.

property TempDir: String ;

Specifies a path to the directory for storing temporary files.

property UseFileCache: Boolean default False;

Defines, whether it is necessary to use report pages caching into the file (see the “MaxMemSize” property).

end;

A set of properties, relating to the report preview:

TfrxPreviewOptions = class (TPersistent)

published

property AllowEdit: Boolean default True;

Enables or disables a finished report editing.

property Buttons: TfrxPreviewButtons;

A set of buttons, which will be available in the preview window.

TfrxPreviewButtons = set of TfrxPreviewButton;

TfrxPreviewButton = (pbPrint, pbLoad, pbSave, pbExport, pbZoom,

pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator);

The available values of this property are the following:

pbPrint - printing

pbLoad – loading from a file

pbSave – saving into a file

pbExport - export

pbZoom - zooming

pbFind - search

pbOutline – report outline enabling

pbPageSetup – page properties

pbTools - tools

pbEdit - editor

pbNavigator - navigation

You can combine any of these values.

property DoubleBuffered: Boolean default True;

A double-buffer mode for the preview window. If enabled (by default), the preview window will not flicker during repainting, but the process speed would be reduced.

property Maximized: Boolean default True;

Defines whether the preview window is maximized.

property MDIChild: Boolean default False;

Defines whether the preview window is MDIChild (for MDI interface organizing).

property Modal: Boolean default True;

Defines whether the preview window is modal.

property OutlineVisible: Boolean default False;

Defines whether the panel with the report outline is visible.

property OutlineWidth: Integer default 120;

Defines width of the panel with the report outline.

property ShowCaptions: Boolean default False;

Defines whether it is necessary to display button captions. When enabling this property, you should limit the number of the displayed buttons in the Buttons property, since all the buttons would not find room on the screen.

property Zoom: Extended;

Default zooming.

property ZoomMode: TfrxZoomMode default zmDefault;

Default zooming mode. The following values are available:

zmDefault – zooming via the “Zoom” property;

zmWholePage – the whole page fits;

zmPageWidth – the page width fits;

zmManyPages – two pages fit.

end;

A set of properties, which relate to the report printing:

TfrxPrintOptions = class (TPersistent)

published

property Copies: Integer default 1;

A number of the printable copies by default.

property Collate: Boolean default True;

Whether to collate the copies.

property PageNumbers: String ;

Page numbers, which are to be printed. For example, “1,3,5-12,17-“.

property Printer: String ;

Printer name.

property PrintPages: TfrxPrintPages default ppAll;

Defines the pages to be printed. The following values are available:

ppAll - all

ppOdd - odd

ppEven - even

property ShowDialog: Boolean default True;

Whether to display a print dialogue.

end ;

A set of properties relating to the report:

TfrxReportOptions = class (TPersistent)

published

property Author: String ;

Report author.

property CreateDate: TDateTime;

Report creation date.

property Description: TStrings;

Report description.

property Name: String ;

Report name.

property LastChange: TDateTime;

The date the report was last modified.

property Password: String ;

Report password. If this property is not blank, a password is required when opening a report.

property Picture: TPicture;

Report picture.

property VersionBuild: String ;

property VersionMajor: String ;

property VersionMinor: String ;

property VersionRelease: String ;

Properties, which detect the number of a version.

end ;

The following events are defined in the TfrxReport component:

property OnAfterPrint: TfrxBeforePrintEvent;

When starting a report. It occurs after handling each object.

property OnBeforePrint: TfrxBeforePrintEvent;

When starting a report. It occurs before handling each object.

property OnClickObject: TfrxClickObjectEvent;

When previewing a report in the preview window. Occurs when clicking the object.

property OnGetValue: TfrxGetValueEvent;

When starting a report. Occurs when an unknown variable is met. An event handler must return the value of this variable.

property OnManualBuild: TfrxManualBuildEvent;

When starting a report. If the handler of this event is allocated, then the FastReport engine is blocked and you thus would have to construct a report manually. See more information in the corresponding chapter.

property OnMouseOverObject: TfrxMouseOverObjectEvent;

When report is previewed in the preview window. Occurs when mouse cursor passes over the object.

property OnUserFunction: TfrxUserFunctionEvent;

When starting a report. Occurs when calling a function, added with the help of the “AddFunction” method. See more in the corresponding chapter.