Pages

Tuesday, August 31, 2010

Jasper Reports

Introduction
When it comes to reports, customers like to change their mind rapidly: "Please, can we add new search criteria !!?", "Oh, that result needs a small change to fit with what we've been wanting", "If only we can group the results by the client's country" and "Oh no, those graph colors hurt my eyes". We can summarize the usual troubles in report development into 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 range 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 whitepaper today is about one of them .. Jasper Report. JasperReport is a well-known open source java reporting engine that gained wide popularity in few years.
Jasper Reports
Jasper Reports is a powerful open source reporting tool that has the ability to deliver rich content onto the screen, to the printer, or into PDF, HTML, XLS, RTF, ODT, CSV, TXT and XML files. It is entirely written in Java and can be used in a variety of Java-enabled applications to generate dynamic content. Its main purpose is to help create page-oriented, ready-to-print documents in a simple and flexible manner.
Jasper Reports is the world’s most complete, most popular Java reporting solution. The Jasper Reports Library is implemented in 100% pure Java in order to seamlessly embed within your application. Using standards-based, open XML report definitions, it allows users to take advantage of the largest and most active community of report designers and developers.
Jasper Reports Architecture
As shown in the below figure JasperReports architecture is based on declarative XML files which by convention have an extension of jrxml that contains the report layout. A lot of third-party design tools were produced to generate your jrxml file in a smooth way (like iReport or JasperAssistant) Design file is supposed to be filled by report's result which is fetched from database, XML files, Java collection, Comma-separated values or Models. Jasper can communicate with those data-sources and more, it can merge any number of data-sources together and manipulates the results of any combinations. This communication goes through JDBC, JNDI, XQuery, EJBQL, Hibernate or existing Oracle PL/SQL. After defining your report design layout in jrxml format and determining your data source(s) jasper engine does the rest of work. It compiles your design file and fills it with results fetched from data-source and generates your report to the chosen exporting format (PDF, Excel, HTML, XML, RTF, TXT …, etc.)


Massively Scalable and Useful Reporting Tools
Jasper Reports enables users to produce reports of any length and complexity. In fact, its built-in virtualization capability means that only available disk storage resources limit report size. High performance reporting features include:
 Multiple data sources such as JDBC, XML, POJO, EJB, MDX, CSV, and custom
 Output in HTML, PDF, XLS, RTF, SWF, ODF, TXT
 Flash-powered reports for interactivity and animation
 Drill down to sub-reports—reports within other reports
 Maps, tables, funnels, crosstabs, charts, barcodes, and many more graphical report components
 Conditional printing and formatting
iReport – Report Designer
The heart of the JasperReports interface iReport—the visual report designer specifically designed for JasperReports. iReport gives administrators and report designers total control over the contents as well as the look and feel of every report. This kind of control ensures their report presentation is every bit as powerful as it is easily understood. With iReport, designers can create web-based and print-ready reports in virtually any style—dashboards, tables, crosstabs, and charts.
iReport is a 100% pure Java application, which is available as a rich client or a NetBeans IDE plug-in. iReport includes full support for JasperReports and JasperServer and enables business users to:
 Create pixel-perfect reports with any layout
 Live-preview reports in any format
 Choose page-orientation or continuous output for printing or screen
 Upload and download reports to and from the JasperServer repository
 Customize and edit Flash based charts
 Build graphic queries for for SQL, MDX, and JasperServer domains (business metadata layer)
 Embed drill-through and hypertext links, including PDF bookmarks
 Rotate text
 Create internationalized and localized reports
iReport includes an integrated chart designer, giving users the flexibility to build animated, interactive charts and maps that are easy to design and powerful to use. Working with the comprehensive samples provided, the design choices are endless.



How we can run the reports
• We can design the report or chart using iReport and deploy in JasperServer. You can directly view the reports from Browser.
• We can design the report or chart using iReport and do the integration with any types of java application using Jasper API.






What is jasper Server
JasperServer is a high-performance report server that can be deployed as either a stand-alone application or integrated with other applications, that provides rich end-user query, reporting, and data analysis capabilities:
 Drag & drop ad hoc query building via an optional rich business semantic metadata layer
 Drag and drop Dashboard Software – with live-refresh, and mash-ups with external content
 A rich business metadata layer for simplifying ad hoc report design
 Integrated in-memory analysis lets users explore their data without requiring a dedicated data warehouse or OLAP cube
 Built-in flash based charting and mapping engages users and enhances applications
 Self-service parameterized web-reporting
 Report scheduling, distribution and historical versioning
 A secure report and metadata repository ensures secure access by user and role
 Access to any data source including relational, XML, Hibernate, EJB, POJO, and custom
JasperServer for Developers
JasperServer is a standards-based architecture delivering unmatched flexibility and scalability for applications
 Based on open standard web technology such as XML, JDBC, Hibernate, Java, and Web Services
 Implemented as a lightweight 100% pure Java server application offering excellent user and data scalability
 Comes bundled with MySQL, Tomcat and Liferay Portal
 Comprehensive Web Services, Java, and HTTP APIs, as well as support for web services from non-Java environments such as .NET (C#), C++, and PHP
 Supports a wide range of proprietary and open source RDBMS, application servers, and operating systems
 Compliant with U.S General Service Administration Section 508
JasperServer for Administrators
Ensure that decision makers and stakeholders get to the right information, when they need it, and in the format they prefer. JasperServer includes several built-in administration functions:
 Report scheduling and distribution – including calendar based recurrences, and historical report versioning
 Export reports to a range of formats such as PDF, HTML, Excel, Flash, Word, RTF, and ODS/ODT
 Manage users, roles, and security through a central repository
 Search-based report repository simplifies finding the report they want
 Built in auditing to determine who ran which report when for compliance or performance optimization analysis

Reports, Ad Hoc Queries, Dashboards And Mash-Ups
Powered by interactive web-based AJAX and dynamic HTML technologies, JasperServer enables end-users to build reports and ad hoc queries without reliance on IT. Through a web browser, they can work with a business view of data that requires no understanding of database concepts or query languages. Simply drag and drop business view items into the query builder, add filters and parameter prompts, and the query is complete. Then use a drag-and-drop report designer to layout and format the report. Reports can be saved, shared, scheduled, and distributed via JasperServer’s repository manager application.

The same technologies permit easy, drag-and-drop dashboarding. Users can build and deploy dashboards that monitor key performance indicators and metrics in near real time. Also, any URL-addressable content can be included in dashboards, enabling mash-ups across internal and external business applications.

Built-in charting provides an at-a-glance understanding of trends and anomalies. With customizable chart themes, users have fine-grained control over chart look and feel. They can also apply chart themes to existing reports and dashboards.

iReport is the report design tool for administrators and report developers to enable total control over the contents as well as the look and feel of every report. Sophisticated pixel-perfect, print-ready, complex reporting is a problem of the past with iReport.
Instant Portal Access
JasperServer support for the JSR 168 portlet specification means it’s easy to extend reporting tools and business intelligence capabilities to anyone in your organization through an enterprise portal. With JasperServer, authorized users can view, request, and update reports, charts and crosstabs within the portal. JasperServer includes Liferay, the leading open source portal server.

Jaspersoft Editions Comparison
The below chart describes the features, products, tools and services that come with each JasperReports package



Look and Feel of Charts
http://www.jaspersoft.com/reports-and-charts-gallery


Jasper API Overview
JasperReports organizes data retrieved from a data source according to a report-design defined in a JRXML file. In order to fill a report with data, the report-design must be compiled first.
The compilation of the JRXML file representing the report-design is performed by the compileReport() method exposed by the JasperCompileManager class.
Through compilation, the report design is loaded into a report-design object that is then serialized and stored on disk ( JasperReport class). This serialized object is used when the application wants to fill the specified report-design with data. In fact, the compilation of a report-design implies the compilation of all Java expressions defined in the JRXML file representing the report design. Various verifications are made at compilation time, to check the report-design consistency. The result is a ready-to-fill report-design that will be used to generate documents on different sets of data.
In order to fill a report-design, one can use the fillReportXXX() methods exposed by the JasperFillManager class. Those methods receive as a parameter the report-design object, or a file representing the specified report-design object, in a serialized form, and also a JDBC connection to the database from which to retrieve the data to fill the report with. The result is an object that represents a ready-to-print document ( JasperPrint class) and that can be stored on disk in a serialized form (for later use), can be delivered to the printer or to the screen, or can be exported into a PDF, HTML, XLS, RTF, ODT, CSV, TXT or XML document.

As you can see, the main classes to use when working with JasperReports:
net.sf.jasperreports.engine.JasperCompileManager
net.sf.jasperreports.engine.JasperFillManager
net.sf.jasperreports.engine.JasperPrintManager
net.sf.jasperreports.engine.JasperExportManager

These classes represent a facade to the JasperReports engine. They have various static methods that simplify the access to the API functionality and can be used to compile an JRXML report design, to fill a report, to print it, or to export to other document formats (PDF, HTML, XML).

In addition to these facade classes, you will also get to work directly with specific exporter classes, in case you need to export your reports to XLS, RTF, ODT, TXT or other document formats for which there is no corresponding helper method in the JasperExportManager, or when you need to configure the export process and adapt it to your specific needs. These exporter implementations can be found in the net.sf.jasperreports.engine.export package of the JasperReports library.

If you need to display the report inside a Swing application, you can use the JRViewer component that is shipped with the library and consists of an embeddable and configurable javax.swing.JPanel component.
The JasperViewer is a stand-alone Swing application that uses the JRViewer component to display reports in proprietary format (serialized JasperPrint objects) or in XML format.
To help with the report design work, JasperReports provides a report design previewer in the JasperDesignViewer class.

No comments:

Post a Comment