Creating Reports with FastReport (FireDAC)

From RAD Studio
Jump to: navigation, search

Go Up to Getting Started (FireDAC)

This article guides you through the creation of your first report built with FastReport and FireDAC.


To create your first report, you need to drop the following components to your form:

Apart from these components you need to add the dataset components that you need to create your report, for example TFDTable, TFDQuery, TFDStoredProc...

In our example we add a TFDQuery.

Add a TfrxDBDataset for each different dataset you want available on your report. Set the DataSet property of the TfrxDBDataset to the appropriate dataset.

FastReport FDComponents.png

The first three components are used to connect to your DBMS.

Use the TfrxDBDataset component to connect to the dataset, for example a TFDQuery. You need as many TfrxDBDataset components as datasets.

Use the TfrxReport to create your report.

If you need to use more than one connection or connect to different DBMSs, you can drop as many TFDConnection components as you need. You also need to drop a TFDPhysXXXXDriverLink to your form or data module corresponding to the DBMS used. Set the Connection property of the dataset to the appropriate TFDConnection.

Adding Datasets to Your Report

To start editing your report double-click frxReport1 and the editor opens.

The TfrxReport component editor area consists of a leftmost Tool Palette and three pages: Code, Data and Page1. On the right you can see the Data Tree with four tabs: Data, Variables, Functions and Classes.

In order to use the information from the DBMS in your report, you need to add the datasets to the Data Tree:

  1. Select the Data page on the left.
  2. Go to Report > Data and the Select Report Datasets opens.
  3. Select the datasets you want to add to the Data Tree.
  4. Click OK
Select Report Datasets.png

Now you can see the dataset information under the Data tab of the Data Tree. In our example we are connecting to the EMPLOYEE.GDB database located at C:\Users\Public\Documents\Embarcadero\Studio\21.0\Samples\Data and we use a TFDQuery with the SQL statement Select * from employee;. After adding the dataset on the Data Tree all the fields from the employee table are available.

Dataset Data Tree.png

Using Datasets

Select Page1 of the FastReport editor. The added datasets are available in the Data Tree. Expanding the dataset nodes allows you to drag and drop the required fields to the page area in order to build the report.

FastReport Employee.png

Fast Report preview

FastReport Preview.png

See Also