Overview
A report is defined by means of a type page. This is divided into different horizontal portions named bands. When the report is joined with the data generating the print, this section is printed many times according to their functions (and according to the rules that the report author has set up). For instance, the page header is repeated at the beginning of every page, while the detail band is repeated for every single read record.
What is a Band
The type page is divided into nine predefined bands to which new groups are added. In addition, Jaspersoft Studio manages a heading band (group header) and a recapitulation band (group footer) for every group.
A band is always wide as the page width (right and left margins excluded). However, its height, even if it is established during the design phase, can vary during the print creation according to the contained elements; it can "lengthen" toward the bottom of a page in an arbitrary way. This typically occurs when bands contain subreports or text fields that have to adapt to the content vertically. Generally, the height specified by the user should be considered "the minimal height" of the band. Not all bands can be stretched dynamically according to the content, in particular the column footer, page footer and last page footer bands.
The sum of all band heights (except for the background) has to always be less than or equal to the page height minus the top and bottom margins.
Band Types
Following there is a brief descriptions of the available bands.
Title
The title band is the first visible band. It is created only once and can be printed on a separate page. Regarding the allowed dimensions, it is not possible during design time to exceed the report page height (top and bottom margins are included). If the title is printed on a separate page, this band height is not included in the calculation of the total sum of all band heights, which has to be less than or equal to the page height, as was mentioned previously.
Page Header
The page header band allows you to define a page header. The height specified during the design phase usually does not change during the creation process (except for the insertion of vertically resizable components, such as a text fields that contain long text and subreports). The page header appears on all printed pages in the same position defined during the design phase. Title and summary bands do not include the page header when printed on a separate page.
Column Header
The column header band is printed at the beginning of each detail column (The column concept will be explained later in the "Columns" section). Usually, labels containing the column names of a tabular report are inserted in this band.
Group Header
A report can contains zero or more group bands, which permit the collection of detail records in real groups. A group header is always accompanied by a group footer (both can be independently visible or not) different properties are associated with a group. They determine its behavior from the graphic point of view. It is possible to always force a group header on a new page or in a new column and to print this band on all pages if the bands below it overflow the single page (as a page header, but at group level). It is possible to fix a minimum height required to print a group header: if it exceeds this height, the group header band will be printed on a new page (please note that a value too large for this property can create an infinite loop during printing).
Group Footer
The group footer band completes a group. Usually it contains fields to view subtotals or separation graphic elements, such as lines.
Column Footer
The column footer band appears on at the end of every column. Its dimension are not resizable at run time (not even if it contains resizable elements such as subreports or text fields with a variable number of text lines).
Page Footer
The page footer band appears on every page where there is a page header. Like the column footer, it is not resizable a run time.
Last Page Footer
If you want to make the last page footer different from the other footers, it is possible to use the special last page footer band. If the band height is 0, it is completely ignored, and the layout established for the common page will also be used for the last page.
Summary
The summary band allows to insert fields concerning total calculations, means, or whatever you want to insert at the end of the report. In other systems, this band is often named report footer.
Background
The background band was introduced after insistent requests from many users who wanted to be able to create watermarks and similar effects (such as a frame around the whole page). It can have a maximum height equal to the page height.
Specifying Report Properties
Now that you have seen the individual parts that comprise a report, you will proceed to creating new one. Click on the "Edit page format" button in the properties view of the report, or right click on the report itself and select "Page Format" from the contextual menu, to see the page properties.
In the dialog that will appear you can change the page dimensions, that probably are the report's most important properties.
A list of standard measure is presented, The unit of measurement used by Jaspersoft Studio and JasperReport is the pixel. However, it is possible to specify report dimension using units of measurement that are more common, such as centimeters, millimeters, or inches. Note that because the dimensions management is based on pixels, some rough adjustments can take place when viewing the same data using different units of measurement. If you are interested in the argument check also the Measure Units Tutorial. In the following table there is a list of the standard measures and their dimensions in pixels.
Page Type | Dimensions in Pixels |
Letter | 612x792 |
Note | 540x720 |
Legal | 612x1008 |
A0 | 2380x3368 |
A1 | 1684x3368 |
A2 | 1190x1684 |
A3 | 842x1190 |
A4 | 595x842 |
A5 | 421x595 |
A6 | 297x421 |
A7 | 210x297 |
A8 | 148x210 |
A9 | 105X148 |
A10 | 74X105 |
B0 | 2836x4008 |
B1 | 2004x2836 |
B2 | 1418x2004 |
B3 | 1002x1418 |
B4 | 709x1002 |
B5 | 501x709 |
ARCH_E | 2592x3456 |
ARCH_D | 1728x2593 |
ARCH_C | 1296x1728 |
ARCH_B | 864x1296 |
ARCH_A | 648x864 |
FLSA | 612x936 |
FLSE | 612x936 |
HALFLETTER | 396x612 |
11X17 | 792x1224 |
LEDGER | 1224x792 |
By modifying width and height, it is possible to create a report of whatever size you like. The page orientations options, Landscape or Portrait, in reality are not meaningful, because the page dimension are characterized by width and height independent of the sheet orientation. However, this property can be used by certain report exporters.The page margin dimensions are set by means of the four options on the Page Margin tab.
Columns
As you have seen, a report is divided into horizontal sections: bands. The page, one or more of which make up a report, presents bands that are independent from the data (such as the title or the page footers) and other bands that are printed only if there are one or more data records to print (such as the group headers and the detail band). these last sections can be divided into vertical columns in order to take advantage of the available space on the page. In this context, the concept of a column can be easily confused with that of a field. In fact, a column does not concern the record fields, but it does concern the detail band. This means that if you have record with ten fields and you desire a table view, ten columns are not needed. However, the element will have to be placed correctly to have a table effect. Ten columns will result when long records lists (that are horizontally very narrow) are printed.
Now we will see how to set up columns in a report with an example. Create a new report from File->New->Jasper Report. Choose as template "Blank A4" and as name "ColumnExample" and as data adapter we can use "Sample DB - Database JBDC Connection" with the following SQL query: select * from orders. Now some fields from the database will be discovered, for our purpose we need only the "SHIPNAME", so double click on it to add to the report fields and hit "Next", another time "Next" and "Finish".
Now from the outline view drag the "SHIPNAME" field in the report in the detail band, resize the detail band and remove the unused band to obtain the result in the following image:
Now go to the Preview tab to see the report compiled:
By default the number of columns is 1, and its width is equal to the entire page, except the margins. The space between columns is zero by default. As you can see in the previous image most of the page is unused. If multiple columns are used, this report would look better. Set from the Page Format dialog the number of columns to two, compile the report and you will see the following result:
In this case, the columns field is set to two to specify the number of columns you want. Jaspersoft Studio will automatically calculate the maximum column width according to the margins and to the page width. If you want to increase the space between the columns, just increase the value of "Space" field. In the following figure there is the same report this time with three columns separated by some blank space:
Advanced Options
From the properties tab of the report there are many other options for the report configuration, now we will see some of this properties. First of all select the report root note from the outline view, and in the properties tab you can see:
- Report Name: It is a logical name, independent form the source file's name, and is used only by the JasperReports library (e.g., to name the produced java file when a report is compiled);
- Title on a new page: This option specifies that the title band is to be printed on a new page, which forces a page break at the end of the title band. So in the first page only no other band than the title are printed, not event the page header or page footer. However this page is still counted in the total pages numeration;
- Summary on a new page: This option is similar to "Title on a new page" except that the summary band is printed as the last page. Now, if you neeed to print this band on a new page, the new page will only contain the summary band;
- Summary with page header and footer : This option specifies if the summary band is accompanied by the page header and the page footer;
- Floating column footer: This option allows to force the printing of the column footer band immediately after the last detail band (or group footer) and not at the end of the column. This option is used, for example, when you want to create tables using the report elements;
-
When no data type: When an empty data is supplied as the print number (or the SQL associated to the report give back no records), an empty file is created (ora a strem of zero byte is given back). This default behavior can be modified by specifying what to do in the case of absence of data. The possible values for this field are:
- NoPages: This is the default value; the final result is an empty buffer;
- BlankPage: This gives back an empty page;
- AllSectionNoDetails: This gives back a page composed of all the bands except for the detail band.
- 1
- 1
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now