Translate

Monday 24 March 2014

Using Styles in Jasper Reports

We have been accustomed to use style sheets or CSS in our HTML codes, parallel to that we can use Styles in Jasper Reports also. It provides same utilities like conditional, non -conditional and could be applied on  any element in the Report.

Now how to create styles, there are two methods basically:
1. External Style Sheet (jrtx file)
2. Declaring Internal Styles in the report itself.

The advantages of using external Style sheet is that it provides modularity and re-usability of the style over large number of reports using similar kind of styles. On the other hand, Internal styles would only contains the styles definitions for a particular report.

How to apply styles in the reports(iReport).

1. Locate the Styles node in the Report Inspector.
2. Right Click on the node and add a new Style
3. Then you could define the properties of the Style in the in the properties pane. Properties like background-color,forecolor, outline,.. etc/
4. You could even click on the Style and add a conditional Style and define conditional styles, like alternate coloring and much more.
5. After defining the styles now in the application part, locate the element onto which you want to apply the style.
6. Select the particular style in the property called Style(could be found in the properties pane) of the Element.

I have created a simple tutorial video demonstrating the Styles in Jasper Reports. Click Here

Download the sample demonstrated in the video tutorial from here. The ZIP file contains :
1. The JRXML File
2. The jrtx Style.

The Sample uses the Sample database so no need to worry about the datasource.

Happy Coding.

2 comments:

  1. hay ankur i want to pass my Jtable data to i report where i can use to design a report i tried to send a TableModel through jasperFillManager
    but i dont know how to retrieve it in i report and use please help me out

    ReplyDelete
  2. Hi Ankur, I want to pass subreport parameters to table element of that subreport. I am using NetBeans with iReport plugin. Please help me.

    ReplyDelete

Please post your queries or suggestions here!!