A report is composed of many elements. Each element has its properties, Size, color, position among many others. Each band, text fields, charts, etc... have their properties. If you iReport, when you select an element, a band or the report itself, the properties appear in the property pane. Properties are covering all aspects of the element/band/report and the most used properties are available in the properties pane. But JasperReports actually gives access to much more properties than the ones visible in the Property pane. | [toc] |
Full list of Properties
A very large set of special properties are now available in the current version. Over the upgrade history, many new properties have enriched the list.
The full API is available at http://jasperreports.sourceforge.net/config.reference.html and http://jasperreports.sourceforge.net/api/index.html.
They have a very wide range of action. From changing the behavior to one specific exporter, to setting sheet names when exporting to Excel or modifying a particular element.
Define a new extra property
Using iReport
After selecting the element on which you wish to add the extra property you will be able to find the property named 'Properties' in the Properties Pane.
Pressing the ellipsis button will open a window where you can add new properties, modify or delete existing properties.
To define a new property it only needs its name and its value. A comprehensive set of special properties including their definition are defined at the bottom of the Add/Modify property window.
In the JRXML
If you are building your report without any report designer, or just as a general knowledge, I will present how properties are defined in the JRXML file. Properties are defined in the property tag and takes 2 arguments, the name and the value.
At JasperReports level
Some properties can be set at report level. If you want to set those property for all your reports on JasperReports Server, you can set the property at the JasperReports level. In <jasperserver-root>/WEB-IN/classes you can find the file jasperreports.properties. This is the file that you need to modify to set some properties to the value you want for all reports running in JasperReports Server. Similarly you can set some properties at iReport level.
- Using iReport go to the menu Tools
- Then go Options
- Open the 'Export Options' tab in the Options Window
That will bring you to the place where you can set some properties for all report that are executed in iReport. There is a menu for the main exporter to access the property specifique to them, or browse the list of properties which don't depend on a specific format. The screen shot below display the common properties for the Excel exporter available in iReport.
Overriding rule
Now we know that we can set properties at different places, we wonder how it works when the same property is set in 2 different places with different values. This is actually very logic behavior. When a property can be set at different levels, the element level override the report level which overrides JasperReports level. So you can set a property in your jasperreports.properties file and override it for a specific report, by setting the property in the report itself as mentioned in the previous chapter. Similarly the value for a property set at element level overrides the value set at reports level.
As a note, the scope of each property is referenced in the JasperReports - Configuration Reference page
Using expression
For all version 4.x and higher, it is possible to pass an expression instead of hard coding a value for a property. This is actually extremely powerful.
Properties value can be dynamically set at execution time! To use an expression you only need to press the "Use an expression" button in the dialog box that is displayed to add/modify parameters in iReport. If you need to modify the JRXML the syntax is also a little bit different.
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