PDA

View Full Version : Customized Reports using SDK? Is that possible?



tpartha@up.com
06-17-2014, 11:04 AM
I am conducting some research on Pentaho and I downloaded the SDK that is up on the website.


There have been four sample files - sample1.java, sample2.java, sample3.java and sample4.java - each of which produces the report in its own fashion. Interestingly, there is a .prpt file in the SDK which is generated from the Pentaho designer.


Questions:


a) Can I customize the layout of the report to my requirements? Does it warrant a change in the .prpt file? If yes, can I change the .prpt file? How?


b) If I don't have the Pentaho designer or other suite of tools on my desktop, can I not make any changes to the reporting layout?


c) Do I definitely need to buy the suite of Pentaho tools in order to be able to generate reports? Or is the SDK enough?

Taqua
08-13-2014, 07:51 AM
The Pentaho Reporting Engine and the Report Designer are open-source and licensed under the LGPL. So no, no need to buy anything to just use it. But once you build a mission-critical application and want support, then getting a support contract might be a good idea.

The reporting engine contains all the API calls necessary to create reports programmatically - and even the Report Designer just uses that API to do its job. So anything you can do in PRD, you can do via normal API calls.

For most parts, I do recommend that users stay within the report-designer as much as possible. Use style- and attribute-expressions for layout customizations and/or use style-sheets for a similar effect. This way you can be guaranteed that your report will continue to run even after updates, as we have a strong policy to maintain compatibility of PRPT files so that old files still run the same way in newer versions of the reporting tools, without need for changes to the file.

We naturally do not make the same assertions about the API - on major releases we take liberty to change the API if needed and some of these changes can be breaking changes, which then require changes in your code.

If you do want to manipulate report definitions - either from scratch or after parsing a PRPT file - then use the methods available on the MasterReport object to add, change or remove elements.

You might want to grab a copy of Will Gorman's "Pentaho Reporting for Java Developers" book for a good introduction to the API. Otherwise download the pentaho-reporting source from GitHub and have a look at the demo project, which contains a fair amount of "from scratch" reports.

https://github.com/tmorgner/pentaho-reporting

I would not recommend to use just the binary jars to try to find your way around the project. We are an open-source project so make use of the sources by looking at the code - or at minimum by adding the code as a reference tool to your own project.

I also created an updated (but unofficial) version of an SDK that contains samples on how to bootstrap projects to run reports and how to extend the reporting engine by creating functions, datasources and report-pre-processors.

https://github.com/tmorgner/pentaho-reporting-oem-sdk