JasperReports Ultimate Guide - Sample Reference - Schema Reference - Configuration Reference - API (Javadoc)
|
|
|
|
JasperReports - Horizontal Sample (version 4.6.0) | ![]() |
|
|
|
Main Features in This Sample | |
| Creating Horizontally-Filled, Multi-Column Reports |
![]() | ![]() | ![]() | ![]() |
|
|
top | |||||
|
|||||
![]() | Creating Horizontally-Filled, Multi-Column Reports | Documented by Sanda Zaharia | |||
|
|||||
| Description / Goal |
| How to create multi-column, horizontally filled reports. | ||
| Since |
| 0.1.0 | ||
|
|||||
|
Filling Report Templates
The report-filling process manipulates sets of data to produce high-quality documents. It represents a very important piece of JasperReports library functionality, because it completes a precompiled report template with its meaningful data. The result is a final document ready to be viewed, printed, or exported to other formats. This is the main purpose of any reporting tool. The following things should be supplied to the report-filling process as input:
The report-filling methods in the JasperFillManager class always produce an output that corresponds to the type of input received. When receiving a file name for the report template, the generated report is also placed in a file on disk. When the report template is read from an input stream, the generated report is written to an output stream, etc. The various utility methods for filling the reports may not be sufficient for a particular application. In such cases, manually loading the report template objects before passing them to the report-filling routines shoud be considered. A report template can be loaded using the JRLoader utility class. This way, one can retrieve report template properties, such as the report name, to construct the name of the resulting document and place it at the desired disk location. The report-filling manager class covers only the most common scenarios. However, one can always customize the report-filling process using the library’s basic functionality. Reporting Data JasperReports can make use of any data that the parent application might have for generating reports because it relies on two simple things: the report parameters and the report data source.
JasperReports templates allow documents to be structured into multiple columns, like a newspaper. The column-count attribute in the <jasperReport /> root element specifies the number of columns in the document.
If this number is not specified, a single-column document is considered by default.
When multiple-column report templates are used, the order used for filling those
columns is important.
There are two possible column filling orders, specified by the printOrder attribute in the <jasperReport /> element:
The reports/HorizontalReport.jrxml template in this sample contains a 3-column report filled horizontally. In order to do that, the only needed steps are:
Running the sample requires the Apache Ant library. Make sure that ant is already installed on your system (version 1.5 or later).
In a command prompt/terminal window set the current folder to demo/hsqldb within the JasperReports source project and run the > ant runServer command.
It will start the HSQLDB server shipped with the JasperReports distribution package. Let this terminal running the HSQLDB server.
Open a new command prompt/terminal window and set the current folder to demo/samples/horizontal within the JasperReports source project and run the > ant test view command.
It will generate all supported document types containing the sample report in the demo/samples/horizontal/build/reports directory.
Then the report will open in the JasperReports internal viewer. |
||||
|
|
© 2001- Jaspersoft Corporation www.jaspersoft.com |