Example: building a simple report

Let's build one of the simplest reports in FastReport:

  1. place three components on a form: TTable (or a TQuery), TfrDBDataSet and TfrReport. Your form should look like this:
  2. link the TTable component with a database (set its DatabaseName and TableName properties).
  3. link the DataSet property of the TfrDBDataSet component with the TTable object. At this stage the forms *dfm code will look like this:
  4. object Form1: TForm1

    Caption = 'Form1'

    object frReport1: TfrReport

    Left = 16

    Top = 8

    end

    object frDBDataSet1: TfrDBDataSet

    DataSet = Table1

    Left = 56

    Top = 8

    end

    object Table1: TTable

    Active = True

    DatabaseName = 'DBDEMOS'

    TableName = 'employee.db'

    Left = 96

    Top = 8

    end

    end

  5. start the report designer (double-click on the TfrReport component);
  6. click on the button "Insert data fields" on the toolbar;
  7. choose the necessary fields in the dialog and press OK button.

Now the report contents all the fields which you've choosed:

It is possible to use automatically generated report as a template, which can also contain graphics, headlines or footers, numbers of pages, etc.

To run the report, press the "Preview" button on the toolbar. FastReport now builds the report and shows its content in the preview window: