Page numbers

0

Hi , 

I have a below scenario 

 

1- I have a main report where  i have multiple subreports say 4 which are defined in individual detail band .

2- Each subreport is itself  might repeat .

3- for example if i have subreport 1 ,subreport 2,subreport 3 ,subreport 4 

4- if subreport 1 have 5 page than page number should print from 1-5 and than subreport 3 have 6 page than page numbers should print from 6-11 .

5- if subreport 2 have 4 pages than page numbers should print from 1-4 and than subreport 3  have 10 pages  than page number should print from 5-14.

6- each subreport is having title band where  i have to show page numbers.

kindly help on this to achive this.

upanshuvaid's picture
Joined: Nov 20 2013 - 2:56am
Last seen: 1 month 3 weeks ago

1 Answer:

0

So if I understand correctly the page numbering should be consecutive over all SubReports, right? 

So either you put them into your MAIN report, then this main report is responsible for incrementing the $V{PAGE_NUMBER} variable. But then you would have to use the Pageheader/-footer of this and wouldn't be able to use the SubReports Title bands.

Of course you also alternatively could pass the current page-number value as SubReportParameter to each subReport.. that would be working fine (Just add outside passed "$P{ParentPageNumber} + $V{PAGE_NUMBER} inside the SubReport(s),) if you just want to print the current but NOT (!) the total page number (so page x/y can't work, as the SubReport don't know how many pages outside will be generated after it has finished itself.)

But luckily there is a new evaluation time in newer versions of JasperReports.... so called "Master". And also two "new" built-in variables $V{MASTER_CURRENT_PAGE} and $V{MASTER_TOTAL_PAGES} were introduced:

If you use a JasperReports version >= 6.x  you can use these variables also in your SubReports Title bands.

Just give it a try!

hth + regards

C-Box

C-Box's picture
2157
Joined: Jul 19 2006 - 5:58pm
Last seen: 12 hours 3 min ago
Feedback
randomness