Chapter 7. Developing Reports

JasperReports report development consists in three steps:

These steps are repeated until the desired result is obtained. This chapter gives a detailed explanation for each of the presented steps.

7.1. Designing Reports

This section explains the activities involved in the design of a report. Before proceeding to this section please ensure that you are familiar with the structure of a JasperReports report. (see Chapter 6, Report Structure).

7.1.1. Adding Styles

To add a style you have to perform the following steps:

Procedure 7.1. Adding a style

  1. Open the Outline View if necessary.

  2. Locate the Styles node in the Outline View.

  3. Right-click on the Styles node and select Add Style from the context menu.

  4. Edit style properties in the Properties View.

7.1.2. Adding Fonts

To add a font you have to perform the following steps:

Procedure 7.2. Adding a font

  1. Open the Outline View if necessary.

  2. Locate the Fonts node in the Outline View.

  3. Right-click on the Fonts node and select Add Font from the context menu.

  4. Edit font properties in the Properties View.

7.1.3. Adding Parameters

To add a parameter you have to perform the following steps:

Procedure 7.3. Adding a parameter

  1. Open the Outline View if necessary.

  2. Locate the Parameters node in the Outline View.

  3. Right-click on the Parameters node and select Add Parameter from the context menu.

  4. Edit parameter properties in the Properties View.

7.1.4. Adding Fields

To add a field you have to perform the following steps:

Procedure 7.4. Adding a field

  1. Open the Outline View if necessary.

  2. Locate the Fields node in the Outline View.

  3. Right-click on the Fields node and select Add Field from the context menu.

  4. Edit field properties in the Properties View.

For certain data source types such as Database Data Source and Custom Data Source, fields can be auto-discovered by analyzing the information provided by the data source. This can be achieved by using the Field Wizard provided by JasperAssistant.

To start the wizard, right-click on the Fields node in the Outline View and select the Field Wizard... option from the context menu.

Procedure 7.5. Field Wizard steps

  1. Data Source selection

    This step allows you to select a data source from the list of data sources that support the field introspection.

  2. SQL query specification

    This step is available only for database type data sources. It allows you to specify or adjust the SQL query that will supply the data for the report. For a custom data source type this step is skipped. Enter the query and press Next button to proceed to the next step.

  3. Field selection

    This step allows you to adjust the data source fields used by the report. After selecting the desired fields, choose the Finish button to update the report.

7.1.5. Adding Variables

To add a variable you have to perform the following steps:

Procedure 7.6. Adding a variable

  1. Open the Outline View if necessary.

  2. Locate the Variables node in the Outline View.

  3. Right-click on the Variables node and select Add Variable from the context menu.

  4. Edit variable properties in the Properties View.

7.1.6. Adding Groups

To add a group you have to perform the following steps:

Procedure 7.7. Adding a group

  1. Open the Outline View if necessary.

  2. Locate the Groups node in the Outline View.

  3. Right-click on the Groups node and select Add Group from the context menu.

  4. Edit group properties in the Properties View.

7.1.7. Adding Sub-datasets

To add a sub-dataset you have to perform the following steps:

Procedure 7.8. Adding a sub-dataset

  1. Open the Outline View if necessary.

  2. Locate the SubDataset node in the Outline View.

  3. Right-click on the SubDatasets node and select Add SubDataset from the context menu.

  4. Edit sub-dataset properties in the Properties View.

7.1.8. Adding Report Sections

To add a report section you have to perform the following steps:

Procedure 7.9. Adding a report section

  1. Open the Outline View if necessary.

  2. Locate the root or a group node in the Outline View.

  3. Right-click on the root or group node and select Add Band sub-menu from the context menu.

  4. In the Add Band sub-menu select the menu item for the desired section type.

  5. Edit section properties in the Properties View.

7.1.9. Adding Report Objects

To add a report object you have to perform the following steps:

Procedure 7.10. Adding a report object

  1. Locate the Palette View.

  2. Select the desired object in the Palette View.

  3. Click in the Designer Editor inside a report section to create the object. Alternatively, holding the mouse button, drag an outline box and then release the button to create the object.

  4. Edit object properties in the Properties View.