Tutorial iReports
Overview
In this tutorial, we will cover the use of creating a document in iReports and integrating it with opentaps. Various techniques are covered to assist in creating a report that can be served as PDF, Excel and other formats. Also covered is how to allow users to enter date ranges, product IDs and other dynamic parameters to constrain the report.
Imagine that we want to report the quantity ordered of each product in our store. This is a fairly straightforward report that involves aggregation, grouping and later on filtering by date and product.
Creating A New Report
There is a wizard to help in creating a report, but it hides important details about the anatomy of a report. Therefore, we will be covering report creation from scratch. First, create a new report using File -> New Document. You should get a blank page and some information in the Document Structure window on the left.
- insert image here with bands
Report Bands
By default there are several sections on the page which are faintly labeled as title, pageHeader, columnHeader, detail, columnFooter, lastPageFooter and summary. These are called bands and they have special behavior with regards to how they print the contents on paginated formats such as PDF.
As you might have guessed, bands such as title, pageHeader, and footer are repeated every page. This is a good place for things that don't change much on a page by page basis, such as the title and page numbers. Usage of lastPageFooter and summary are beyond the scope of this tutorial. For now we can hide the bands we are not going to work with by dragging on the borders and reducing the band height to 0. Alternatively, you can right click on a band and select Band Properties and reduce the size of the bands to 0 by hand.
For the purposes of this tutorial, we will be using only the title, pageHeader, columnHeader, detail and pageFooter bands. Collapse the other bands to size 0 until the page looks as follows.
- Insert image with revised bands
Inserting Text
Next we're going to insert some static text for the title. To insert a static text element, either select it from the dropdown menu or click on the icon. Both are shown below.
- Insert images for static text icon and dropdown
Once you click on the desired location for the element, a re-sizable box appears. Move the box to the title band and resize it to take up the entire band. You'll notice that iReport provides snapping and hints when you're aligned with the edge. We will use these extensively when aligning data so that the output is tidy and suitable for spreadsheet output.
- Insert image for static text resized
To change the text, you can right click the element and select Properties. Alternatively, you can double click on the element in the Document Structure window to bring up the same properties dialog. It has several tabs and allows you to specify all kinds of details from the font to the alignment details. For now let's just change the text as follows.
- Insert image of static text being changed.
After closing this window, our title is now displayed. We can use the toolbar on top to change the alignment, font and other details.
- Insert image of toolbar
Once you get it vertically and horizontally centered with a nice bold size, it should look something like this,
- Insert image of title
That is all there is to entering static text.