Reporting Server/Jasper Report Template Customization
Contents |
When a user creates a report from an Ad-Hoc view it is possible to select a template to set style information and header and footer. Openbravo delivers a set of standard templates which you can use as the starting point for a custom template.
Custom Logo
To use the standard templates with a custom logo you only need to upload a new logo in the following folder: /System/resources.
Creating a new template
To create a custom template several steps are required:
- create a custom jrxml file (see [ here] for an example and upload the template in a location in the Jasper repository
- add a Spring bean definition in the WEB-INF/applicationContext.adhoc.xml file
- restart jasper
We will discuss each of these steps separately.
Custom jrxml file
An example template can be found File:OBReportingTemplate A4 portrait.jrxml. The template consists of two parts, a section for styling and to show a header/title and footer.
The example template file refers to a logo image file. In your customization you can also use images, make sure to store them in the referenced location in the Jasper Server repository.
When you are finished with the jrxml file you have to upload it to a specific location in the jasper server: /Public/Templates, as a jrxml file.
Use the template when generating a report
You can use the template in the adhoc view by saving the adhoc view as a report. In the popup there is a field Custom Report Template where you can select your template.
Default template
To change the default template used when creating a report from ad-hoc view you have to edit the WEB-INF/applicationContext-adhoc.xml file. Set the defaultTemplateUri value to a path to the jrxml file you uploaded into the repository.
<util:map id="reportGeneratorDefaultConf"> <entry key="templatesFolderUri" value="/public/System/Templates"/> <entry key="defaultTemplateUri" value="/public/System/Templates/OBReportingTemplate_A4_landscape.jrxml"/> <entry key="publicFolderUri" value="#{configurationBean.publicFolderUri}"/> </util:map>
Advanced Topic
An advanced topic which can be added to a template is to show the parameters used to generate the reports. This is not delivered in our standard product, so if there is a requirement for this feature it needs to be developed. The following File:Show parameters.zip file contains a sample template and java files which are needed. The java code needs to be compiled to class files and placed on the jasper server.