Book Image

Pentaho Reporting 3.5 for Java Developers

Book Image

Pentaho Reporting 3.5 for Java Developers

Overview of this book

Pentaho Reporting lets you create, generate, and distribute rich and sophisticated report content from different data sources. Knowing how to use it quickly and efficiently gives you the edge in producing reports from your database. If you have been looking for a book that has plenty of easy-to-understand instructions and also contains lots of examples and screenshots, this is where your search ends. This book shows you how to replace or build your enterprise reporting solution from scratch with Pentaho's Reporting Suite. Through detailed examples, it dives deeply into all aspects of Pentaho's reporting functionalities, providing you with the knowledge you need to master report creation. This book starts off with a number of examples to get you familiar with the tools and technology of the Pentaho Reporting Suite. Then, with additional examples, it goes into advanced subjects such as charting, sub-reporting, cross tabs, as well as API generation of reports. There are also details and examples on extending Pentaho's open source reporting engine. The reader will learn the ins and outs of Pentaho Report Designer, including a cheat sheet with all the available short-cut keys, to make report design efficient and painless. Embedding reports into your Java application can be difficult. With Pentaho Reporting it's just a few lines of code. The book provides examples of how to embed reporting into your J2EE and client Java applications, as well as showing you how to build dynamic reports from scratch using Pentaho Reporting's simple Java Bean-based report generation API. Setting up and integrating a reporting server in an enterprise environment can be arduous. In addition to learning how to build great embeddable reports, you'll also learn how to combine Pentaho Reporting with Pentaho's BI Server for a zero-code, easy-to-configure, enterprise reporting solution.
Table of Contents (19 chapters)
Pentaho Reporting 3.5 for Java Developers
Credits
Foreword
About the Author
About the Reviewers
Preface
Index

Feature overview


In this quick introduction to the various features available in Pentaho Reporting 3.5, you'll have an executive summary of how Pentaho Reporting works and what it can accomplish for your reporting needs. The topics that will follow are covered in more depth in later chapters of the book.

An advanced reporting algorithm

The reporting algorithm is at the heart of Pentaho Reporting. This algorithm manages the layout and rendering of the entire report, no matter which output format is being rendered. This algorithm combines a reporting template, along with a dataset on the fly, in order to generate the final report. There is no unnecessary compilation step. All other Pentaho Reporting features can be described in the context of the overall reporting algorithm.

This algorithm allows reports to render with a page header and footer, a report header and footer, group headers and footers, as well as a details band. The reporting algorithm traverses the dataset multiple times to render the report. In the first pass, the algorithm performs calculations and determines how to separate the data into groups, along with calculating the height and width of text and images. After the initial pass, the algorithm traverses the dataset a second time, in order to render the output.

A multitude of available data sources

Pentaho Reporting defines a standard Java API for accessing data. Many data source implementations are made available with Pentaho Reporting. The most commonly used implementations include JDBC Database Connectivity, XML XPATH capability, Multidimensional OLAP Data Access using MDX, and simple Plain Old Java Object (POJO) support.

Additional data sources that are available include a Pentaho Data Integration data source, a Hibernate Query Language (HQL) data source, and a Pentaho Metadata data source. With Pentaho's Data Integration data source it is easy to use Excel, Logs, or other file formats as inputs to a report without the need to write any code.

All of these data sources interact with the reporting engine through a standard API, which is easy to extend.

The following data sources are available with Pentaho Reporting:

  • Swing TableModel

  • Java Reflection (POJO)

  • Hibernate HQL

  • JDBC SQL

  • OLAP MDX

  • XML XPATH

  • Pentaho Data Integration

  • Pentaho Metadata

By combining Pentaho Reporting's data source functionality with Pentaho's Data Integration engine, most known data formats and systems are available for input. This includes combining data sources into a single report. An example might include a Microsoft Excel file, on a remote shared drive, with a plain text log file from an HTTP server.

A wide variety of output formats

Pentaho Reporting has the ability to render to the most widely used output formats, including Adobe's PDF standard using the iText Library, Microsoft's Excel standard using the POI Library, and HTML, all highlighted in the following image. Other formats available include XML, plain text, Rich Text Format (RTF), and Comma-separated values (CSV). In addition to these output formats, a Pentaho Report can be rendered in Swing and directly printed using PostScript formatting, allowing print previewing capabilities.

Following is the screenshot showing one such report obtained using Report Designer.

Pixel accurate rich formatting

Reports defined in Pentaho Reporting can specify at the pixel level where objects such as text or images should render. Using Pentaho Report Designer, it is easy to align fields and group items that need to stay aligned. While not always possible due to different format types such as XML, CSV, and plain text, the three main graphical outputs—HTML, PDF, and Excel—strive to look as similar as possible.

Rich formatting includes TrueType system font selection, the ability to render geometrical shapes and lines, along with the ability to include images and other objects in a report. This rich formatting is specified under the covers through styles similar to Cascading Style Sheets (CSS), separating out the format from the report detail. This makes it easier to modify and maintain reports, and also to apply corporate styles through the report wizard.

Embedded charts

The Pentaho Reporting Engine and suite of tools make it easy to embed charts in reports, using the JFreeChart engine. Many chart types are available, including Bar, Histogram, Pie, and Line charts.

Report parameterization

Pentaho Reporting provides easy-to-use tools to parameterize a report, allowing users to specify ranges and other values that customize the output of a report. Parameter values can be selected from a list of hardcoded values or driven from a query. With parameterization, end users may control the amount of information that is displayed on a report. The following screenshot is an example of parameter input from within Pentaho's Business Intelligence Server:

Formulas and style expressions

Report builders may define custom formulas and style expressions, using the OpenFormula standard, allowing for calculated values and dynamic formatting in their reports, such as aggregations, number formatting, as well as traffic lighting.

Sub-reports

Pentaho Reporting allows report developers to include sub-reports within a master report. This provides a powerful capability, which allows reports to contain different smaller reports, both side-by-side and within the various bands of a report. These sub-reports may be based on different data sources.

This capability makes it possible to reuse detailed reports within multiple primary reports, as well as enabling a single report template to render multiple times in a single PDF document, allowing painless printing of a large number of reports. The following screenshot is an example of a report that includes a separate chart sub-report:

Cross Tab Reports

Cross Tab Reports present data in a spreadsheet-like format, making it easier to view summaries of data. Cross Tab Reports present both row and column headers, as well as cells of data, all of which can be customized through report elements.

Interactive reporting

While most reports are static after being rendered, a subset of reporting includes functionality such as drill through, pivoting, and other interactivity. Pentaho Reporting provides a straightforward Java and JavaScript API for manipulating a report after it has been rendered, allowing report builders to create very interactive reports. Pentaho Reporting's Interactive functionality is available when rendering a report in HTML, Excel or Swing. Links to external documents can also be added to PDF documents.

The following screenshot shows a report with links, that when clicked launches a more detailed report:

Rich authoring tools

While it is possible to build Pentaho reports using either XML or a Java API, most reports begin as templates built by the Pentaho Report Designer. Pentaho Report Designer is a What-You-See-Is-What-You-Get (WYSIWYG) report editor that exposes the rich set of features provided by the Pentaho Reporting Engine. In addition to building a report from scratch, the Report Design Wizard, included as a part of the Pentaho Report Designer, walks a report author through building a report, which will then be displayed in the Report Designer for further customization.

Reporting server

As a part of the Pentaho suite, reports created by Pentaho Reporting may be published, executed, and scheduled on Pentaho's Business Intelligence Server. The BI Server offers authentication and authorization, as well as a central repository, to manage your business reports. The BI Server also hosts the web-based Ad Hoc Reporting user interface for creating Pentaho Metadata-based reports. By combining the use of Pentaho Report Designer and Pentaho's BI Server, there is no need to write any code to get your business up and running with Pentaho Reporting.

Java API for building reports

Pentaho Reporting comes with a well-documented Java API for building reports from the ground up, so developers can stick with the Java programming language when customizing existing report templates or building reports from scratch. This Java API allows developers to create and modify the various sections of a report, including the various header, footer, group and detail bands, along with creating and modifying objects within each section of a report.

Extensibility

Pentaho Reporting is designed from the ground up in pure Java, exposing many interfaces for extension. From implementing basic formulas and functions that can be embedded in reports, to writing a custom data source or output format, Pentaho Reporting's source code and API interfaces are well documented and easy to work with.

A business friendly open source license

One very attractive feature of Pentaho Reporting is its license. Pentaho Reporting is available for free under the GNU Lesser General Public License. This license allows other open source and proprietary projects to embed Pentaho Reporting without fear of large license fees or viral open source limitations. As an open source project, developers also have unprecedented access to the engine and to a large group of software developers within the Pentaho Reporting community. This community includes open discussion forums, Internet Relay Chat (IRC) along with commercial support and licensing, if required.

Pentaho reporting roadmap

In addition to these features, Pentaho Reporting is in active development. Please visit http://reporting.pentaho.org to learn more about what additional features and functionality are being considered for development, or to access early release versions of the product.