Book Image

JasperReports 3.6 Development Cookbook

By : Bilal Siddiqui
Book Image

JasperReports 3.6 Development Cookbook

By: Bilal Siddiqui

Overview of this book

<p>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. While such reports are pivotal in managing business information more effectively, creating and customizing them can get tedious.<br /><br />This book will give you recipes to solve common JasperReports problems to make your life easier. It will take you through complex examples related to JasperReports with step-by-step instructions on how to solve them.<br /><br />The author's experience in creating reports enables him to share over 50 recipes to develop crystal-clear business reports using the capabilities of JasperReports and the amazing features provided by its visual report designer tool: iReport.<br /><br />This cookbook will arm you to develop user-friendly reports by using multiple types of data in the same report, thereby saving your time in sorting, arranging, or extracting data and making the whole process effortless. First you will learn to do basic things such as creating, sizing, positioning, and enhancing the titles, headers, footers of the report. You will move on to working with the body and footer of the report, including using parameters to filter records during report processing and implementing nested hierarchy. Second, you will learn to enhance the look and feel of your report by deploying and reusing styles, and by using designs, textual effects, background images, and watermarks. You will also learn to use mathematical and logical expressions such as counting the number of records with a particular field value, grouping records, applying styles on your data based on logical or mathematical conditions, and so on.<br /><br />Then you will be able to do advanced things such as working with a variety of data sources: relational data, XML data, model beans of Java applications, and also multiple relational databases at once. You will learn to build a cover page and table of contents for multi-page reports, display multi-dimensional page numbering, and much more. You will be able to design simple and multi-level summary reports, cross-tabs with dynamic rows and columns, create bar charts, and display data trend graphs in your reports. Lastly and very importantly, you will be able to generate reports from Java Swing applications after you learn how to use JavaWrappers for your JasperReport.</p>
Table of Contents (13 chapters)
JasperReports 3.6 Development Cookbook
Credits
About the Author
About the Reviewers
Preface

Creating a Java wrapper for your report


This recipe teaches you how to design a simple wrapper class in Java that wraps JasperReports functionality to process and compile an existing JRXML file, fetch application data, and combine the processed JRXML with application data to generate and save your JasperReport in PDF format.

Getting ready

Refer to the installPostgreSQL.txt file included in the source code download for this chapter to install and run PostgreSQL, which should be up and running before you proceed.

The source code of this chapter also includes a file named copySampleDataIntoPGS.txt, which helps you create a database named jasperdb9 and copy sample data for this recipe into the database.

You will need Java Development Kit (JDK) version 1.6.X to compile and run the Java application of this recipe. You will find all the necessary downloads and instructions on Sun's official website. After installing JDK, you will also set the JAVA_HOME environment variable to point to the main folder...