7.4. JasperReports

ReportServer supports the creation of graphical reports by using the OpenSource library JasperReports Library (http://www.jaspersoft.com). It is primarily designed to specify pixel perfect reports to directly print them, or to export them as a PDF at a later time. In Jasper reports, reports are defined in a specific XML dialect (JRXML). Reports can be directly written by using a text editor, however, in practice reports are mostly drawn up by using the open report designers IReports (http://community.jaspersoft.com/project/ireport-designer).

A JasperReport always consists of exactly one master report and one or several sub-reports. There is an XML file for the master report and for each sub-report with the extension .jrxml. These files are required to embed the report in ReportServer.

For further information on the creation of reports by using JasperReports refer to the relevant documentation of JasperSoft (http://community.jaspersoft.com/documentation).

To embed Jasper reports in ReportServer switch to the Report management and create a Jasper report in a folder. As with dynamic lists, in the following dialogue you can give a name and a description to the report as well as a unique key to call up the report by URL, for instance.

To complete the configuration you have to upload the master report (i.e. the corresponding .jrxml file) as well as all sub-reports.You can create sub-reports either by the Add sub-report button, or by dragging and dropping it to the respective window.

During report execution, sub-reports will be loaded exclusively via the subreport's name; possible path information will be ignored. Therefore, it doesn't matter how you locally organized the files belonging to a report, you need not adapt them in order to use them in ReportServer. However, you must ensure that no two sub-reports have the same name. Conversely, however, you note that ReportServer never loads sub-reports from the local server file system. Accordingly, all sub-reports always have to be registered together with the master report. Furthermore, it is not possible to share sub-reports between several reports.

Finally, you have to assign a datasource to the report. Here, you can exclusively draw from relational databases as the source of your data. In ReportServer there is no need to enter queries as you do with dynamic lists for they have already been included in the .jrxml files.

Just like dynamic lists, Jasper reports can be controlled by parameters. They will be created in the reports themselves (for detailed information refer to JasperReports/Ireport Ultimate Guides http://community.jaspersoft.com/documentation). In ReportServer you have to additionally configure all parameters entered in the report by the parameter management (tab at the bottom of the screen). Here, ReportServer will support you by automatically creating parameters from the master report. This function can be activated via the Suggest parameter button in the tool bar. We note that the automatic extraction of parameters is rudimentary and for may need manual adjustments for more complex parameter settings. The configuration of the parameters is otherwise identical to the configuration of dynamic list parameters.

Note that when you include images, if you plan to export these to HTML, you need to set isLazy to true as shown in the following example:

<image scaleImage="Clip" vAlign="Bottom" isLazy="true">
   <reportElement x="0" y="0" width="555" height="250"/>
   <imageExpression class="java.lang.String">"/path/to/your/image.gif"</imageExpression>
</image>

More information can be found here: https://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRImage.html.

7.4.1. Unformatted Excel Output: Plain Excel

Jasper Reports attempts to present pixel-perfect reports across all output formats. As a result, when exporting to Excel, the reports are usually well-formatted visually. However, numbers often appear as text rather than numeric values, which complicates further data processing.

Please note that the Excel export of Jasper reports essentially "draws" the report into Excel. This is handled by the Jasper engine and can vary in quality.

To address this issue, ReportServer provides an option ''Plain Excel'' to the Jasper report, which allows you to add an additional datasource to a Jasper report. When this function is activated, you will be offered an additional output format: ''Excel (plain)''. This option presents the result of the query execution as an Excel file, allowing for a cleaner, more straightforward export that does not attempt to render the pixel-perfect layout of the report. Please consider using this ''Plain Excel'' option for better data processing.

7.4.2. Exporting Jasper reports containing images to HTML

When exporting a Jasper report that includes images to HTML, you may encounter an issue where the images are not initially visible in the export. This behavior is explained in detail here: https://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRImage.html.

To ensure images appear correctly in your HTML export of a Jasper report, consider setting the isLazy property to true as shown in the following example:

<image scaleImage="Clip" vAlign="Bottom" isLazy="true">
   <reportElement x="0" y="0" width="555" height="250"/>
   <imageExpression class="java.lang.String">"/path/to/your/image.gif"</imageExpression>
</image>