JasperReport Pass Page Number To Subreport

4.1k views Asked by At

I am passing page number information from my main report to a footer subreport. In the main report, I have declared subreport parameters pageTot and pageNum. They are mapped through the wizard to parameters from the main report $V{PAGE _ COUNT} and $V{PAGE _ NUMBER}. In the subreport, I have declared the two parameters pageNum and pageTot. In their parameter properties, I have unchecked use as a prompt, and set them both as java.lang.integer types. I then replaced the variables in the text field expression of the text fields to use the new parameter names $P{pageNum} and $P{pageTot}. While this mapping is successful for the pageNum parameter, the pageTot parameter is not displaying the correct number. For a 27 page test report, pages 1-26 say the total number of pages is 38. The last page, 27, the total changes to 13. I have also noticed that the original formulas were both mapped to $V{PAGE _ NUMBER}. How can I get the correct number of pages for the total?

1

There are 1 answers

0
C1pher On BEST ANSWER

This is what I was able to find:

$V{PAGE_COUNT}
    - The number of records that display on the page.
$V{PAGE_NUMBER} 
    - The page number.  When evaluated at 'now', you get the current page.
    - When evaluated at 'report', you get the last page, or total.

I could not find a way (iReport does not support) to evaluate a parameter at 'report' time, so I was not able to get the total number of pages to display. I ended up moving this feature out of my SubReport and into the main report.