Developers Manual/Creating reports using Jasper Reports/Creating the Template using iReport
Contents |
Introduction
iReport is a powerful, intuitive and easy to use visual report builder/designer for JasperReports written in 100% pure java. This tool allows users to visually edit complex reports with charts, images, and subreports. iReport is integrated with leading open source chart libraries for java.
The data to print can be retrieved through several ways including multiple JDBC connections, TableModels, JavaBeans, XML, MDX, EJBQL, Hibernate, etc.
Setting up your environment
Downloading and Installing iReport
You can download a version of iReport from sourceforge.net and for installation steps you can go the iReport's documentation page
NOTE: Please keep in mind that Openbravo 2.35 (MPx) and 2.40 do not support JRXML files generated by iReport 2.0.4 or newer so please use the 2.0.3 version.
Defining classpath for database connectivity
To be able to connect to Oracle database, you need to include the ojdbc14.jar in iReport's classpath.
- Go to Options > Classpath
- Click on Add JAR
- Browse and look for the lib folder under the Openbravo's root source, and select the ojdbc14.jar
- Click on Save Classpath
Defining a database connection
- Go to Data > Connections/Data Source
- Click on New
- Select Database JDBC Connection, and click Next
- Fill the Name textfield: Openbravo
- Select oracle.jdbc.driver.OracleDriver from the drop-down list
- Fill the Server Address and Database. You can click on Wizzard to generate the connection string.
- Fill the Username and Password with your Openbravo's user installation, e.g. TAD. Check the Save Password option.
- You configuration should look like this
- Test your connection
- Save your connection
Creating a Template
You can use the iReport's Report Wizzard to create a Jasper Report template.
- Go to File > Report Wizzard and follow the instructions
- Select Openbravo from Connection/Data Sources
- Then you fill the SQL query valid sql sentence: e.g.
SELECT M_Product_ID, Name, Description FROM M_Product ORDER BY Name
- Select all the fields from the list. Click Next.
- Select no group in the Grouping screen. Click Next.
- Select a installed template, e.g. Columnar Layout > ClassicC.xml
- Click Finish
- Your Jasper Report template should look like this.
- Save your template. Following the Openbravo's source structure you should save it under ad_reports folder. e.g. You can save it with m_product.xml filename.
AppsOpenbravo
|-src
|-org
|-openbravo
|-base
|-erpCommon
|-ad_actionButton
|-ad_background
|-ad_callouts
|-ad_combos
|-ad_forms
|-ad_help
|-ad_process
|-ad_reports --> .jrxml templates
|-ad_tasks
|-ad_workflow
|-businessUtility
|-info
|-reference
|-security -> login
|-utility
|-ws -> Web Services
|-erpReports
Testing your Report
- Go to Build > Execute (with active connection)
- You will see a report like this.
Adding your Report to Openbravo ERP
You can now add your Jasper Report to Openbravo ERP.
Category: Development






















