Bands in FastReport

Top  Previous  Next

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 FastReport 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. FastReport 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.

 

_img79

 

When running the report you will see that the objects in the finished report are printed in the proper positions on the page.

 

_img80

 

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:

 

- “PageHeader” band : displayed at the very top of each page

- “PageFooter” band : displayed at the very bottom of each page

- “ReportTitle” band : 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” band : displayed in the free space at the very end of the report