Bands in FastReport

Top  Previous  Next

Bands in FastReport

Top Previous Next

      Bands are used for logically placing the objects it contains at a location on the output page.  When placing an object in a band, such as “Page Header,” we tell the report engine that the given object must be displayed at the top of each page of a finished report. Similarly, the “Page Footer” band is displayed at the bottom of each page together with all the objects it contains. Let us demonstrate it with an example. We’ll create a report, which contains the “Hello!” text at the top of the page, a current date to the right of it, and a page number at the foot of the page (to the right).

 

      Open the FastReport designer and click the “New report” button in the toolbar. You will see a report template, which already contains three bands:  “Report title,” “Master data,” and “Page footer.” Let us remove the “Master data” band for a while (to do that, click either on any free space inside the band, or on its header, and then remove it by pressing the “delete” key or using the corresponding section in the context menu). Now let us add a new band (“Page header”). To perform this, click the “Add band” button and select “Page header” from the drop down list. We see that a new band is added to the page. At the same time, the existing bands were moved down. FastReport designer automatically positions bands on the page, and, as a result, header-bands are positioned on the top, data-bands are in the middle, and footer-bands are at the bottom.

 

      Now let’s add some objects. Add a “System text” object in the “Page header” band and select “System variable” in its editor “[DATE]” (you should remember that the date can be displayed in a “Text” object by typing “[DATE]” in its editor). We add a “Text” object, which will contain the “Hello!” text in the “Report title” band. Note you can see, the text object, which displays page number, is already added to the “Pagefooter” band.

 

_img79

 

      When running the report, you will see that the objects in the finished report are allocated on the page in the appropriate position.

 

_img80.zoom71

 

      Thus, bands are responsible for object positioning in required places. Depending on band type, we can add objects either at the top or at the bottom of the page, on the first page, or on the last one. The basic bands, which we would need in most reports, work in the following way:

 

- “Page header” band is displayed at the very top of each page;

- “Page footer” band is displayed at the very bottom of each page;

- “Report title” band is displayed at the top of the first page, but below the “Page header” band (depending upon the “TitleBeforeHeader” page property assigned in the object inspector);

- “Report summary” band is displayed at the very end of a report, at white space.