Dynamic Jasper Reports Automated in Talend

Dynamic Jasper Reports Automated in Talend

Overview

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.

Talend Workflow

select

Context Variables

select

Components of Talend workflow

capiq_params: Excel Metadata file

Dynamic Column names can be mapped in the Excel metadata

select

Excel Metadata File Component Configuration

select

tFlowToIterate

select

tJava_1

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.

capiq_mysql_db

This tMySqlInput component is used for providing DB connection to

  • Connect dev or prod environments as per arguments.
  • Execute the queries and produce results.

tMap

select

tJasperOutput

select

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

tJava_2

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.

Few templates with different column numbers:
2 – Column Template: select 3 – Column Template: select 4 – Column Template: select

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.

Conclusion

In this blog, we discussed about creating n number of dynamic Jasper reports integrating Java components.

References

2235 Views 7 Views Today