-->

Java code for creating Pentaho reports and this re

2019-08-31 02:02发布

问题:

I am looking for java code in which have to display Pentaho reports in HTML/PDF format with Data Integration(.ktr file) as input to the Pentaho reports.

回答1:

First of all most probably there is official documentation to API, chapter "Embedding the Reporting Engine Into a Java Application"

Code it pretty simple

Create report using visual tool, assign data source as .ktr file, and code as example in tutorial.

Only u might need to customize path to *.ktr file which either can be made via official API (most probably) or prepare report *.prpt before to start report.

Pentaho Report Designer generate files with prpt extension which is just a zip file with a lot of xml files inside. So u need to unpack it (java.util.zip) and inside in folder datasources file kettle-ds.xml. Use any suitable xml parser to change path to *.ktr file and pack it back. Then pass customized report to report engine.