Creating a custom template with Jaspersoft Studio
Create the Structure
Creating template is nothing more than a standard report where some elements have a precise and fixed name that is used by the Jaspersoft Studio engine to understand where to place every element.
The First thing is to create new report from File -> New -> Jasper Report. We can start with blank report or selecting one of the other templates as a starting point.
Now Design the template as par your requirement .Creating the template is same as that of generating the report.
I have created like this
Now switch to the Preview mode and look if the result is what you want and if it is allright you can continue with the export operation.
Export the Template
To start the export wizard select click File -> Export as Report Template.
In the first dialog you will see all the resources that will be exported. Between these resources you can fine the template and other files used by it, in our example you will see the one image. In this step you will need also to select the destination folder, where the template and all his resources will be placed.
When you have finished press Next.
Here you can define the categories where your template will be visible inside the New Report Wizard. You can select any number of categories or your own category. To define a custom category you need only to type its name inside the text area on the bottom and press the Add button. Then your category will be added to Selected Categories list. Then your category will be added to Selected Categories list.
At this point you can see two different steps:
- The first one, and the one that should appear follwoing this tutorial, is a congratulations step. It means that the template you designed is valid for the report type you have selected in the previous step.
- The second one is a list of error messages if the template you designed is not valid for the selected type because of some design errors. For example for a template with Tabular type is expected a table in the summary band. If this table is not found it’s probably a design error. In this step all the design errors found are listed so you can look to what is wrong and fix it.
In both the cases we can export the template and all resources by clicking the finish button.
In second case may your template should not work while generating the report.
Add the Templates location to Studio
- Now you have to put your custom template for studio.
- Navigate to Windows ->Preferences. A new Preferences window open.
- From the Left panel expand the category Jaspersoft Studio and select Template Locations.
- Click on New and browse the folder where you have saved template jrxml file.
Test the new template
- Open Jaspersoft studio.
- Navigate to File > New > Jasper Report.
- Select the template that you have added. Then Report will open as shown below:
Helical It Solution
Best Open Source Business Intelligence Software Helical Insight is Here