Book Image

Pentaho 8 Reporting for Java Developers

By : Jasmine Kaur, Francesco Corti
Book Image

Pentaho 8 Reporting for Java Developers

By: Jasmine Kaur, Francesco Corti

Overview of this book

This hands-on tutorial, filled with exercises and examples, introduces the reader to a variety of concepts within Pentaho Reporting. With screenshots that show you how reports look at design time as well as how they should look when rendered as PDF, Excel, HTML, Text, Rich-Text-File, XML, and CSV, this book also contains complete example source code that you can copy and paste into your environment to get up-and-running quickly. Updated to cover the features of Pentaho 8, this book will teach you everything you need to know to build fast, efficient reports using Pentaho. If your interest lies in the technical details of creating reports and you want to see how to solve common reporting problems with a minimum of fuss, this is the book for you.
Table of Contents (25 chapters)
Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Dedication
Preface

Feature overview


In this quick introduction to the various features available in Pentaho Reporting 8, 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 and 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 and JNDI database connectivity, XML XPATH capability, and multidimensional OLAP data access using MDX and MongoDB NoSQL database support.

Note

Java Naming and Directory Interface (JNDI) is a Java API for a directory service that allows Java software clients to discover and look up data and objects via a logical name, decoupling the implementation from the configuration and settings.Online Analytical Processing (OLAP) is an approach to answering multidimensional analytical queries swiftly in computing. Multidimensional Expressions (MDX) is a query language for OLAP databases. Much like SQL it is a query language for relational databases.

Additional data sources that are available include a Pentaho Data Integration data source, a Hibernate Query Language (HQL) data source, a Pentaho Metadata data source, a scripting data source (in JavaScript, Python, TCL, Groovy, and BeanShell), a simple table defined as a static list of rows and columns, and other advanced data sources (OpenERP data access, community data access, and sequence generator).

Using 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 these data sources interact with the Reporting Engine through a standard API, which is easy to extend.

The following screenshot shows the available data sources in Pentaho Reporting:

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 screenshot. Other available formats include XML, plain text, RTF, and 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.

The following is a screenshot showing one such report obtained using Report Designer and rendered in PDF (top left), Microsoft Excel (top right), HTML (bottom left), and CSV (bottom right):

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 the 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 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, as shown in the following image:

Embedded charts

The Pentaho Reporting Engine and suite of tools make it easy to embed charts in reports, originally developed using the JFreeChart Engine. Many chart types are available, including bar, histogram, pie, and line charts, as shown in the following diagram:

Report parameterization

Pentaho Reporting provides easy-to-use tools to parameterize a report, allowing users to specify ranges and other values to 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.

Subreports

Pentaho Reporting allows report developers to include subreports 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 subreports may be based on different data sources. The following screenshot is an example of a report that includes a separate chart subreport:

Cross tab reports

Cross tab reports present data in a spreadsheet-like format, making it easy 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. The following image shows how a cross tab report looks:

Interactive reporting

While most reports are static after being rendered, a subset of reporting includes functionalities 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, collapses/expands the row in detail:

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, as shown in the following screenshot, for further customization:

Reporting server

As part of the Pentaho suite, reports created by Pentaho Reporting may be published, executed, and scheduled on Pentaho's Analytics Platform. The Pentaho Analytics Platform offers authentication and authorization, as well as a central repository, to manage your business reports. The Pentaho Analytics Platform 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 Analytics Platform, 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 the 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.

Pentaho reporting website

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