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.
Installation
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:
- In the menu, select Package / Open package file (.lpk)...
- Open the file Lazarus/components/lazreport/source/lazreport.lpk
- 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 SQLite04.zip and
unzip to this folder.
- Start Lazarus and open project SQLite04.
- 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.
- Double-clicking on the frReport icon brings up the report designer.
- In the report designer, we started by adding a "Report title" band.
To the band, a rectangle was added with the text "GuitarClub".
- 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.

- In the designer, the report can be previewed with File / Preview.
When everything is as desired, the report layout is saved with File / Save.
- In our application, we show a report by clicking btnReport:
procedure TForm1.btnReportClick(Sender: TObject);
begin
frReport1.LoadFromFile('guitarclub.lrf');
frReport1.ShowReport;
end;
Note: the file guitarclub.lrf was generated at design time (see above).
|
|