6 min read

A complete report is structured by composing a set of sections called bands. Each band has its own configurable height, a particular position in the structure, and is used for a particular objective. The available bands are: Title, Page Header, Column Header, Detail 1, Column Footer, Page Footer, Last Footer, and Summary.

A report structured with bands is shown in the following screenshot:

iReport 3.7

Besides the mentioned bands, there are two special bands which are Background and No Data.

Band

Description

Title

Is the first band of the report and is printed only once. Title can be shown on a new page. You can configure this from the report properties discussed in the previous section of this chapter. Just to review-go to report Properties | More… and check the Title on a new page checkbox.

Page Header

Is printed on each page of the report and is used for setting up the page header.

Column Header

Is printed on each page, if there is a detail band on that page. This band is used for the column heading.

Detail

This band is repeatedly printed for each row in the data source. In the List of Products report, it is printed for each product record.

Column Footer

Is printed on each page if there is a detail band on that page. This band is used for the column heading. If the Floating column footer in report Properties is checked, then the column footer will be shown just below the last data of the column, otherwise it will be shown at the bottom of the page (above the page footer).

Page Footer

Is printed on each page except the last page, if Last Page Footer is set. If Last Page Footer is not set, then it is printed on the last page also. This band is a good place to insert page numbers.

Last Page Footer

Is printed only on the last page as a page footer.

Summary

Is printed only once at the end of the report. It can be printed on a separate page if it is configured from the report Properties. In the following chapters, we will produce some reports where you will learn about the suitability of this band.

Background

Is used for setting a page background. For example, we may want a watermark image for the report pages.

No Data

When no data is available for the reports, this band is printed if it is set as the When no data option in the report Properties.

Showing/hiding bands and inserting elements

Now, we are going to configure the report bands (setting height, visibility, and so on) and format the report elements.

  1. Select Column Footer from the Report Inspector. You will see the Column Footer – Properties on the right of the designer.
  2. Type 25 in the Band height field.
  3. iReport 3.7

  4. Press Enter. Now you can see the Column Footer band in your report, which was invisible before you set the band height.
  5. A band becomes invisible in the report if its height is set to zero. We have already learned how to change the height of a band. We can also make a band invisible using the Print When Expression option. If we write new Boolean(false) in Print When Expression of a band, then that will make the band invisible, even though its height is set to greater than zero. If we write new Boolean(true), then the band will be visible. It is true by default.

  6. Drag a Static Text element from the Palette window and drop it on the Column Footer band. Double-click on Static Text and type End of Record, replacing the text Static Text.
  7. iReport 3.7

  8. Select the static text element (End of Record). Go to Format | Position and then choose Center. Now the element has been positioned in the center of the Column Footer band.
  9. In the same way, insert two Line elements. Place one element at the left and another at the right of the static text.
  10. Select both the lines. Go to Format | Position, and then choose Center Vertically . The lines are now positioned in the center of the Column Footer vertically.
  11. Select both the lines and go to Format | Size and then choose Same Width. Now both the lines are equal in width.
  12. Select the static text element (End of Record) and the left line. Now go to Format | Position and choose Join Sides Right. This moves the line to the right, and it is now connected to the static text element.
  13. Repeat the previous step for the right line and finally choose Join Sides Left. Now the line has moved to the left and is connected with the static text element.
  14. In the same way, change the column headers as you want by double-clicking the labels on the Column Header band. Now, the columns may be Product Code, Name, and Description.
  15. Now your report design should look like the following screenshot:
  16. iReport 3.7

  17. Preview the report, and you will see the lines and static text (End of Record) at the bottom of the column.

By default, the Column Footer is placed at the bottom of the page. To show the Column Footer just below the table of data, the Float column footer option must be enabled from the report Properties window.

iReport 3.7

Sizing elements

We can increase or decrease the size of an element by dragging the mouse accordingly. Sometimes, we need to set the size of an element automatically based on other elements’ sizes. There are various options for setting the automatic size of an element. These options are available in the format menu (Format | Size).

Size Options

Description

Same Width

This makes the selected elements of the same width. The width of the element that you select first is used as the new width of the selected elements.

Same Width (max)

The width of the largest of the selected elements is set as the width of all the selected elements.

Same Width (min)

The width of the smallest of the selected elements is set as the width of all the selected elements.

Same Height

This makes the selected elements of the same height. The height of the element that you select first is used as the new height of the selected elements.

Same Height (max)

The height of the largest of the selected elements is set as the height of all the selected elements.

Same Height (min)

The height of the smallest of the selected elements is set as the height of all the selected elements.

Same Size

Both the width and the height of the selected elements become the same.

Position

Description

Center Horizontally (band/cell based)

The selected element is placed in the center of the band horizontally.

Center Vertically (band/cell based)

The selected element is placed in the center of the band vertically.

Center (in band/cell)

The selected element is placed in the center of the band both horizontally and vertically.

Center (in background)

If the Background band is visible and if the element is on the Background band, then it will be placed in the center both horizontally and vertically.

Join Left

Joins two elements. For joining, one element will be moved to the left.

Join Right

Joins two elements. For joining, one element will be moved to the right.

Align to Left Margin

The selected element will be joined with the left margin of the report.

Align to Right Margin

The selected element will be joined with the right margin of the report.

LEAVE A REPLY

Please enter your comment!
Please enter your name here