Adding a Dataset to a report
Bands
Bands are used for placing the objects they contain at particular locations on the output page. When placing an object in the “PageHeader” band we tell the report engine that the given object must be displayed at the top of each page in the finished report. Similarly, objects in the “PageFooter” band are displayed at the bottom of each page. Let's demonstrate this with an example. We’ll create a report containing “Hello!” at the top of the page, the current date to the right of it and the page number at the foot of the page on the right hand side.
Open the designer and click the “New report” button in the toolbar. You will see a report template which already contains three bands: “ReportTitle”, “MasterData”, and “PageFooter”. Let's remove the “MasterData” band for a while (click either on any free space inside the band or on its header and remove it with the “Delete” key or "Delete" in the context menu). Now let's add a new band (“PageHeader”). Click the “Add band” button on the object toolbar and select “PageHeader” from the drop-down list. We see that a new band is added to the page. At the same time the existing bands are moved down. Designer automatically positions bands on the page - header bands at the top, data bands in the middle and footer bands at the bottom.
Now let’s add some objects. Add a "System text" object to the "PageHeader" band and in its editor select "[DATE]" from the System variable drop-down list (you should remember that the current date can also be displayed in a "Text" object by typing "[DATE]" in its editor). Next add a “Text” object containing “Hello!” to the “ReportTitle” band. A "Text" object displaying the page number has already been automatically added to the “PageFooter” band.
Add additional "Text" objects with band type names as you see on the next picture. Set for all new objects red frame and property "Align" to "baClient". Enlarge also font size and change font text to better see band positions. Report design is on the following picture.:
When running the report you will see that the objects in the finished report are printed in the proper positions on the page.

So, bands are responsible for positioning objects on the page. Depending on the type of band, we can print objects at the top or the bottom of a page and on the first or the last page. The basic bands needed in most reports work as follows:
Band |
Position on page |
PageHeader |
displayed at the very top of each page |
PageFooter |
displayed at the very bottom of each page |
ReportTitle |
displayed at the top of the first page - this can be before or after the "PageHeader" band, depending on the page's "TitleBeforeHeader" property (found in the object inspector after clicking on any free space on the page) |
ReportSummary |
displayed in the free space at the very end of the report |
Report consists of several bands that allow you to display values on different parts of the report. Bands are of different types and are divided into those that do not need data from tables or queries and band that need data from tables and queries.
We display the main title at the beginning of the report on "ReportTitle" band, date, page number, or comment on the "PageHeader "or on the "PageFooter" band. If you want data will be displayed at the end of the report, put them into "ReportSummary" band.
We can use bands of specified type on the report or not. We can add them via the toolbar.
The most important properties of bands are:
AllowSplit |
Specifies whether a band can be printed on multiple pages. If the band can not be printed on more than one page and is higher than the height of the page that is available for printing, the lower part of the band does not appear. |
Stretched |
Specifies whether the height of the band should be adjusted to the height of the objects in it. |
PrintOnFirstPage |
Specifies whether the band is displayed on the first page. Only page header and page footer have this property. |
PrintOnLastPage |
Specifies whether the band the band is displayed on last page. Setting available only for page footer. |
ReprintOnNewPage |
Specifies whether the band is displayed on the next page. Setting os available only for page header. |
StartNewPage |
Specifies whether the band is displayed at the beginning of the next page. Setting is available for bands with dataset except group footer. |
Data Bands
Now we will learn how to print data from database tables or from queries. What is considered to be a 'table' or a 'query'? They consist of data organized into lines (records or rows) which contain one or more columns (fields). To print this sort of data FastReport uses a special type of band, the various bands which are named "...Data". To print a whole table or just some of its rows and fields, you must add one or more of these bands to the report, connect them to the table and place field objects within them. When FastReport builds the report, the bands will be printed on the output page, once for each record in the table. If there is no free space left on the output page for a band, a new output page will be created by the report engine before continuing.
Bands that need data are:
Name |
Description |
MasterData |
Data of the 1st data level repeated for each master data record. Must have DataSet defined. |
GroupHeader |
Group title printed at the beginning of group. Condition on which field data is grouped must be defined. |
GroupFooter |
Displayed after group. |
DetailData |
Data of the 2nd data level repeated for each detail record. |
SubdetailData |
Data of the 3rd data level repats once for each sub-detail record. |
Adding a Dataset to the Report
To make the Delphi component (and the data connected to it) available to the report, any dataset used in the report must be enabled. Do this through the “Report>Data...” menu item in the designer, selecting the required datasets in the opened dialogue.
