Where are iReport’s report Templates?
This article supersedes my article from a year ago about finding templates in iReport. I’m leaving the old article up because it’s useful if you’re still using iReport 3.1. But unless there is some odd but compelling reason to stick with the old version, you should really upgrade to iReport 3.7.
iReport uses report templates to enable a designer to develop new reports quickly. iReport ships with many prebuilt templates, and you’re free to add more templates yourself. Your self-built templates will include appropriate fonts, color schemes, logos, etc.
There are eight distinct templates that ship with iReport 3.7. (Technically there are eighteen templates… but that counts portrait and landscape versions of essentially the same thing as different templates.) Let’s look at what the default templates give you.
Blank
This is pretty self-explanatory. Normally the blank template is not used with the report wizard. Instead it’s used to create a brand new report nearly from scratch. In fact, it works really poorly in the report wizard. It doesn’t automatically put any fields into the report. I’m not sure if this is intentional or not… it’s called “Blank”, so I guess it’s not surprising that the report is blank. If you attempt to define a report group the wizard gets stuck. This is bug 17579.
Cherry
This shows some good basic functionality. It uses the font Times New Roman; I’m not a big fan, but it’s a reasonable choice for printed reports. It incorporates some nice best practices. The formatting is all done with styles rather than applying formats to each field. The detail rows alternate background colors. This is done by putting a frame around all elements in the detail row. It’s generally better to use a frame like this rather than setting the background color for each individual field.
This example shows a simple list of Caldecott winning picture books formatted using the Cherry template.
Coffee
This shows an interesting use of frames that go beyond the normal borders. More interestingly, it includes an image that extends off of the page. A PDF export will show the coffee stain image extending to the page borders. A HTML export will show the entire image. It extends above and to the right of the defined page size. Exporting to XHTML will clip the image on top, but it still extends out to the right.
The fonts are a mix of Times New Roman and Arial. Frankly, I find the overall impression of the fonts and colors to be ugly. But it’s still an interesting template with good ideas to draw from.
Flower
There’s more cool stuff in this one. First, it uses the background band. This is an underused feature, so it’s nice to see it highlighted in this template. Even better, it’s not just a trivial background image. It includes two separate copies of the flower image so that it can be more prominent on the first page and then slide up to the top on other pages allowing more room for the data. It’s accomplished with simple Print When Expressions that test for “$V{PAGE_NUMBER} == 1” and “$V{PAGE_NUMBER} > 1”. Even better, it shows other components in the background band. In this case it’s three pie charts. Granted, there’s minimal business benefit to showing thee pie charts of random data in your reports. But the ideas may be reused for more practical solutions.
Although not important to the final report, the template also shows a nice way of adding notes to a JRXML file.
Leaf
This is a nice clean template. No new ideas are introduced here. So I’ll take this moment to mention that all of these templates set the report language to Groovy rather than Java (hooray!), and they are all A4 size rather than letter size (hooray! or boo! depending on where you live).
Four versions are included to show different colors, but there are no differences beyond the colors.
Silhouette
Is that image über-cool like an iPod ad? or is it vaguely inappropriate at work? Nevermind. The more interesting detail is the use of the background tab for a nicely formatted way of displaying the page number. “Page 1 of 18” never looked so good before.
Simple Blue
Yuck. No reason to beat around the bush here. That’s an ugly template. None of the other templates labeled the “book_publish_year” field which I used for grouping. The other templates were better for the omission, but I guess it’s a good reminder that it’s possible to include the column name in the template. Interestingly, this template sets no fonts at all. At runtime it will just inherit the system default.
Tree
This is the only remaining template that reproduces the old iReport 3.0 “Columnar” template style. I added a few fields to the SQL query compared to the samples above in order to make the idea clear. The fields in each “row” are lined up in rows rather than in columns. This is especially useful when you have large data values that don’t display well in columns.
Where are these Templates?
A year ago I had to write up a pretty detailed set of instructions to find the templates. Now in iReport 3.7 it’s as easy as you could reasonably hope. You’ll find them here:
<iReport dir>/ireport/templates
What’s Next?
Now that you’ve found the templates you can get started customizing them for your own needs. You’ll find some tips in my article Creating Report Templates in iReport.