Free Pascal

SQLite Database Tutorial: Report generator

Lazarus provides LazReport, a report generator, for adding reporting capabilities to applications.
It uses a visual report designer to create so-called "banded" reports.
LazReport includes its own Object Inspector and a report previewer, that can also print the report at runtime.


The LazReport components are not installed by default, they don't appear on the toolbar right after the installation of Lazarus.
To install LazReport in the Lazarus IDE:

  1. In the menu, select Package / Open package file (.lpk)...
  2. Open the file Lazarus/components/lazreport/source/lazreport.lpk
  3. Click Use / Install

The next time Lazarus is started, it should show a LazReport tab in the component palette.

Adding a report

For this project, create a folder FPlaz\SQLite04, download and unzip to this folder.

  1. Start Lazarus and open project SQLite04.
  2. For our report, the following components were added:

    - frDBDataSet1, with its property DataSet set to queryMembers;
    - frReport1, with its property DataSet set to frDBDataSet1;
    - frDesigner1.
  3. Double-clicking on the frReport icon brings up the report designer.
  4. In the report designer, we started by adding a "Report title" band.
    To the band, a rectangle was added with the text "GuitarClub".
  5. We added a second band of the type "Master data".
    To this band, reactangles were added for the various fields that we want to display.

    Report designer
  6. In the designer, the report can be previewed with File / Preview.
    When everything is as desired, the report layout is saved with File / Save.
  7. In our application, we show a report by clicking btnReport:

    procedure TForm1.btnReportClick(Sender: TObject);

    Note: the file guitarclub.lrf was generated at design time (see above).