Exporting Reports with iReport Designer

by Giulio Toffoli

When you click the preview button in the designer tool bar, iReport performs a set of operations to create the final report. The first operation is to compile the JRXML source file in a Jasper file. This first step can fail if the elements are not correctly positioned (for example, if an element is placed outside of a band), or if an expression in the report has errors and cannot be compiled.

If the compilation runs successfully, the produced Jasper file is loaded and filled using the active connection or data source. This second operation can again lead to errors, for example if the referenced database is not active, an invalid query has been provided, or a null field produced an error in an expression during the filling process. Finally, if all operations complete without error, the report is displayed in the integrated viewer.

Errors are shown in the Report Problems Window, and operation results are shown in the iReport output, both of which share the bottom of the iReport screen.

Figure 1
Figure 1
Figure 2
Figure 2

Reports can be exported in several formats by clicking Save in the preview tool bar or by setting a proper preview format in the Preview menu:

Figure 3
Figure 3
Figure 4
Figure 4

To export again a report that has not been modified, click Run again in the preview tool bar. Running a report again is useful when a subreport changes, when the datasource changes, or when you want to execute the report with different input parameters.

Figure 5
Figure 5

When you set a preview format, the report is automatically exported to the chosen format when you click Preview, and the corresponding viewer application is opened, for example a PDF viewer or OpenOffice.

On Windows and MacOS, iReport is able to identify the proper viewer for each format automatically based on the system defaults. However it is possible to manually set the viewer application for each format by selecting Tools > Options > iReport > Viewers:

Figure 6
Figure 6

If the final report does not contain any pages, iReport displays the following message instead of the document:

Figure 7
Figure 7

This is not an error, iReport is just saying that the report is empty. This can happen under several circumstances, usually when the SQL query or the data source used to fill the report has not provided any data. If you see this message, check your database connection and test the query in your report.

If you're embedding your reports in another application, now you need to deploy your reports.

 

Feedback
randomness