Thursday, June 13, 2013

Using Talend as a Datasource for a Jasper Report


In Talend Open Studio, the tJasperOutput component can be used to create a Jasper Report created in iDesigner.  Talend's flows -- say from a tAccessInput -- provide the data.

To use tJasperOutput, create a job with a flow leading to a tJasperOutput.  This example starts with a tAccessInput component.
tJasperOutput with Data Provided by MS Access
The schema of the input (Access) must match that of the report.  If there is a field "Field1" in Access, then there must be an similarly-named field created in iReport.  This post uses a table with 3 Text fields: field1, field2, field3.

Access Table with 3 Fields Defined
 The report created in iReport contains a title, column headers, and a detail band.  The detail band refers to 3 fields (field1, field2, field3).  The fields are of type java.lang.String.  Numbers -- even in if defined consistently in the data source, tAccessInput, tJasperOutput and iReport -- will throw a cast error.

iReport with 3 Fields Defined

To hook the Talend job up with the JRXML generated by iReport, use the Component View.  Specify the location of the JRXML, the iReport executable, the output file name (TalendTestReport.pdf), and the type (PDF).

tJasperOutput Configuration
The result of running the job is a PDF (TalendTestReport.pdf) with data provided by tAccessInput.

PDF Generated by Talend
The tJasperOutput component doesn't support parameters defined in iReport, so use fields to have Talend communicate with Jasper.

If your input is a CSV, take a look at this example of tJasperOutputExec to reduce the amount of components needed.

Creating a Jasper Report from a CSV with Talend Open Studio

No comments: