Book Image

JasperReports for Java Developers

Book Image

JasperReports for Java Developers

Overview of this book

JasperReports is the world's most popular embeddable Java open source reporting library, providing Java developers with the power to easily create rich print and web reports. This book shows you exactly how to get started, and develop the skills to get the most from JasperReports. The book steers you through each point of report setup, to creating, designing, formatting, and exporting reports with data from a wide range of datasources, and integrating JasperReports with other Java frameworks. Starting with the basics of adding reporting capabilities to your application, and creating report templates you will first see how to produce your reports through the use of JRXML files, custom ANT targets, and then see preview them in both the browser and the native browser of JasperReports. Getting data into your reports is the next step, and you will see how to get data from a range of datasources, not only databases, but XML files, and Java Objects, among others. You will create better looking reports with formatting and grouping, as well as adding graphical elements to the report. You will export your reports to a range of different formats, including PDF and XML. Creating reports will be made even easier with a walkthrough of the iReport Designer visual designing tool. To round things off, you will see how to integrate your reports with other Java frameworks, using Spring or Hibernate to get data for the report, and Java Server Faces or Struts for presenting the report.
Table of Contents (13 chapters)
12
Index

What This Book Covers

Chapter 1 covers JasperReports' history, and its features and gives us an overview of the steps involved in generating reports using JasperReports.

Chapter 2 shows us how to embed JasperReports into client and server-side Java applications. We will install JasperReports and learn how to identify and install required libraries. We will also see how to set up our development and execution environment to add reporting capabilities to Java applications.

InChapter 3, we create our first static JasperReports both programmatically and by using the ANT tool. We will see how to work with JRXML and binary report templates to generate reports in JasperReports' native format. We will then learn how to view these reports.

InChapter 4, we learn how to create dynamic reports. We will do this by embedding SQL queries in the JRXML report template, or by passing the database data to the compiled report via a datasource.

InChapter 5, we cover how to use datasources other than databases to create reports. Specifically, we will learn to create reports from empty datasources, Java objects, TableModels, XML data, and also from our custom-created datasources.

InChapter 6, we cover how to create elaborate layouts for our reports by adding background images or text to a report, logically grouping report data, conditionally printing report data, and creating subreports.

InChapter 7, we cover how to take advantage of JasperReports' graphical features and create reports with graphical data like geometric shapes, images, and 2-D and 3-D charts.

Chapter 8 discusses advanced JasperReports' features like creating crosstab (cross-tabulation) reports and adding anchors, hyperlinks, and bookmarks. We then see how to work with subdatasets and how to execute snippets of Java code by using scriptlets. This chapter also shows how to display report text in different languages.

InChapter 9, we cover how to export our reports to all formats supported by JasperReports; these include PDF, RTF, Excel, HTML, CSV, XML, and plain text. We also see how to direct exported reports to a browser.

Chapter 10 covers iReport, which is a report designer that can help us visually generate JRXML templates. This chapter shows how to install and get started with iReport. iReport can be used to do everything that we have covered so far in this book and this chapter shows us how.

Chapter 11 covers the integration of JasperReports with three of the most popular Java web application frameworks around — Spring Web MVC, JavaServer Faces, and Struts. We shall also see how to generate reports with data obtained using Hibernate, which is a popular Java Object Relational Mapping tool.