Creating and Customizing Templates

You can create templates from scratch or edit existing templates and save them as new templates.

Creating a New Template

If you want to start fresh with your template, create a new one.

To create a new template:

1. Go to File > New > Jasper Report.
2. From the New Report wizard, select a template from which to start. Click Blank Letter, and Next.
3. Choose where you want to store the file, and name the new template. Click Next.
4. For creating a template, there is no need to connect to a data source. Select One Empty Record - Empty rows and click Finish.

One Empty Record Data Source

An empty report opens, containing the following bands:

     Page Header
     Column Header
     Column Footer
     Page Footer
5. Right-click on the report root node in the Outline, and select Create Group. The Group Band dialog box appears.

Group Band Dialog Box

6. Name your group and click Next.

Group Layout Dialog Box

The Group Layout dialog box appears.

7. Leave both Add the Group Header and Add the Group Footer checked, and click Finish.

Your report is similar to the one in “Report Containing Group Header and Footer”.

Report Containing Group Header and Footer

Customizing a Template

Now that you have a blank template, you can customize it to suit your preference. For example, you can add your company name and logo, page numbering, add a background for your report, and set band and column sizes. You also use this procedure to make changes to an existing template.

To customize a template:

1. To add a graphic, drag an Image element into the band where you want the image to appear. This is usually the Title band.

For more information about the Image element, see Graphic Elements.

2. To add a title you want to see in your template, drag a Static Text element to the Title band. Style the text in the Properties tab. For more information about Static Text elements, see Text Elements.
3. If you want the background to cover the entire page, right-click the element in the Outline and choose Maximize Band Height. Otherwise, set the Background band to the size you want. Drag an Image element into the Background band to create your background.
4. You can add page numbering to the Page Footer band. Drag a Page Number element into the band, and place it where you want the page number to be. You can also add a Page X of Y element if you prefer.
5. If you want a label in the Column Header band, add a Static Text element with the text “Label”.
6. To set styles for your report’s text, add a Text field to the Group Header and a Text field to the Detail band. Set the text of the first Text field to “GroupField” and the text of the second Text field to “Field”. Format the text as you like.
7. Save your template file.
8. Click the Preview tab. Your template should like something like the one in “Template Preview”.

Template Preview