This blog is subject the DISCLAIMER below.

Thursday, June 05, 2008

Java Reporting: JasperReports

One of the purposes of software industry is to automate the routinely activities and summarize the data in decision supporting format which is commonly known by reports, that’s the reason why customers used to consider software as the wizard stick that will turn their usual mess into charming charts, graphs and visualized datagram's. On the other side, reports are considered as the developers' usual nightmare; you can obviously notice the misery look over the victim's face when get assigned to the reports module.

When comes to reports, customers like to change their mind rapidly "Please, can we add new search criteria !!?", "Oh, That result need a little bit change to fit what we dreamt with", "If only we can group the results by clients country" and "Dear, the graph colors hurt users eye".


We can summarize the usual troubles in report development in the following points:

  • Core changes: it's usual to modify/add report core logic to reflect business changes or usability enhancements.
  • Results exporting: There is a wide set of formats to export your report to, such as: HTML, text, PDF, MS Excel, RTF, ODT, Comma-separated values, XML or image.
  • Complicated reports sub-reports and cross-tabs reports are good example.
  • Charts reports: visual chart e.g. Graph, Pie, 3D Pie, Bar, XY Line, Scatter, Meter and Time series.

A lot of frameworks, tools, libraries, and 3rd parties applications were introduced to facilitate the reporting process and to remove the overhead of the mentioned points, our topic today is about one of them .. JasperReport.
JasperReport is a well-known open source java reporting engine that gained wide popularity in few years. Unlike other tools –e.g. Crystal Reports- it's based on java and doesn't have its own expression syntax.

Let's read what's written in wikipedia about JasperReports features:

  • PDF, HTML, Microsoft Excel, RTF, ODT, CSV and XML files. The engine allows report definitions to include charts, with the rendering provided by the JFreeChart library which supports many chart layouts, such as Pie, Bar, Stacked Bar, Line, Area, Scatter Plot, Bubble, and Time series.
  • Multiple sources can be merged together. The data can be retrieved from defined data sources such as JDBC, CALS Table Models, JavaBeans, EJBQL, XML, Hibernate, and Comma-separated values, and additional data sources can be added to the JasperReports framework by plugging in a custom JRQueryExecuter. An extension is available to use Oracle PL/SQL stored procedures as a data source.
  • Scriptlets may accompany the report definition, which the report definition can invoke at any point to perform additional processing. The scriptlet is built using Java, and has many hooks that can be invoked before or after stages of the report generation, such as Report, Page, Column or Group.
  • Sub-reports.

As a victim developer I've passed through the report development iterations by its whole faces (designing, implementing, changing, changing, changing and more changing), but I was little more lucky to work with Jasper through this long cycle in sub-reports, Crosstabs, Charts and graphs.

The main difficulty I faced while working with jasper was the shortage of resources and tutorials, which is a common problem among other developers so I hope to transfer my personal experience with JasperReports in more detailed articles.

Continue to the next posts: 2, 3, 4

References:

http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/jasperreports/index.html
http://en.wikipedia.org/wiki/Jaspersoft
http://www.javaworld.com/javaworld/jw-09-2002/jw-0920-opensourceprofile.html


1 comment:

James said...

Hi
This is a really good series (part 1&2 of reporting) - would you be interested in reposting this to JavaLobby? If so, contact me on james at dzone dot com and we can arrange it.

Regards
James