Table of Content
Dynamic Jasper is a great tool for designing and creating simple or complex dynamic reports. Talend is not only used as the most common tool for data transformation. It is also used for dynamic Jasper report generation using tJasperInput component.
Automation with context parameters is the most important value add to it. It helps to resolve many challenges involved in dynamic report creation such as on the fly changes like column name, report header, date, and so on. It helped developers in saving the report generation time.
Components of Talend workflow
capiq_params: Excel Metadata file
Dynamic Column names can be mapped in the Excel metadata
Excel Metadata File Component Configuration
This Java component is used to:
- Provide configurable dev or prod connection so as to connect “dev” to dev environment and “prod” to production environment.
- Provide java.util.Date to display current date in the report.
- Replace the column name in JRXML file.
This tMySqlInput component is used for providing DB connection to
- Connect dev or prod environments as per arguments.
- Execute the queries and produce results.
Fill the following context variable details:
- Jrxml file – Provide the JRXML file path
- Temp path – Provide temporary path location
- Destination path – Provide destination path location
- File Name/Stream – Provide out file name from the Excel metadata file
Note: JRXML file name should be fetched from the Excel metadata file
This component is used to revert the column names from the jrxml template xml file and to make it ready for next iteration. This will help us create Jasper reports if the query, column, environment, and jrxml file are configurable.
JRXML File Templates
These are the Jasper report templates used to create reports. To make the reports dynamic, JRXML file templates need to be prepared based on the column numbers and to be referred as and when required. Reports can be created with any number of columns such as 1 to n and can be kept in the repository for future use.
Excel metadata explained
- query_column – Contains n number of queries used to generate reports
- out_file_name – Names of output reports such as “idx4_fin_est_sector_rollup_reports”
- jrxml files – Contains Jasper report templates used to create reports
- jrxml_file_name – Name of the jrxml_file for the report
For example, if the query has 2 columns in the output, then map it to the “2_column_report.jrxml”. If the query has 3 columns in the output, then map it to the 3_column_report.jrxml” and so on.
In this blog, we discussed about creating n number of dynamic Jasper reports integrating Java components.
- Talend Java components code examples are available in GitHub.
GitHub Location: https://github.com/treselle-systems/talend_java_component