Translate

Wednesday, 25 September 2013

How to make global header and footer in Jasper Reports?

Hi,
Suppose there are reports ABX,BNC and KLM  which have a same header and footer Then what you can do is create a master Report suppose mainReport, in there you add 3 subreports in the details section and then  and give the path of the the three reports ABX,BNC and KLM.  
You will have to specify the input control in the mainReport which user will have to enter suppose REPORT_SELECTION. Now you will have to decide the disctinct codes for each of the subreports . Suppose in this case I assign codes as :
ABX-1
BNC-2
KLM-3 
It  would accept the 1,2,3 from the user as input from the user in the parameter $P{REPORT_SELECTION} on the basis of this very choice of user it will trigger the presence or absence of the subreport.(Here 1,2,3 are just the cases could be anything like A,B,C or name itself like "ABX","BNC","KLM" )
Now to trigger the appearance of the subreport on the basis of this parameter $P{REPORT_SELECTION} ,which is entered by user we need to write the print when expression. The printwhen expression(which you would find in the property of the subreport element) you need to specify it as  : $P{REPORT_SELECTION}  ==1 (This will be for the report ABX ). So in this way the expression will vary. and you will get the desired subreport.
Please keep in mind that in the subreports header and footer is removed .
Here the input control REPORT_SELECTION is included on the mainReport so would be global too, and even you could accept the values of other parameters required by the reports and then pass it on to the subreports.So the parameters or input controls would be turned global too.
Hope that above explanation helps .


Happy Coding!!

No comments:

Post a Comment

Please post your queries or suggestions here!!