Jump to content
Changes to the Jaspersoft community edition download ×

How to know total pages in a report


Recommended Posts

hi every one,

[p] i want total pages in a report, because i want to print continued.. at a page footer if report has more then one page this text doesn't come if it has only one page and not to repeat in last page, this can be achived if able to get the total pages in first page only, please help me on this matter,



$V{PAGE_NUMBER} gives the current page number if i change this variable evaluation time to report then i wil get the total page number but the problem is i can print this number by putting it on report by changing its evalution time but i want it in variable because in my case i have to use this variable in print value expression when? so any one know how to get total pages please help me[/p]


Post edited by: dgmanu, at: 2007/02/15 04:54

Post edited by: dgmanu, at: 2007/02/15 04:54

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

  • 8 months later...
  • 4 weeks later...



do the jasperrepors masters have some idea of how to solve this issue??


I mean, it's a very usefull skill to perform actions or take decisions at outer levels of report (headers), based on whats going on with detail report data, not just to be able of draw things based on it


I've tried to solve it playing with subreports and retrieving values from them, but always face the same problem: variables placed at headers can't to react based on detail data


please let me know if there's some way to bypass this issue

Link to comment
Share on other sites



Maybe I don't fully understand what you are talking about and a better example of what you need to achieve would be more appropriate.


But I just wanted to let you know that scriptlets are a very flexible way of implementing a complex data processing.

You could have a scriptlet that with every detail make the appropriate modifications of some internal data that you can then leverage at higher levels.


I hope this helps.


Link to comment
Share on other sites

  • 2 years later...

I have what I think is a similar problem to the original poster here. And it's not one that can be solved with the "Page i of n" trick.

I have a static set of lines that I want to draw on the background of every page... EXCEPT the last (summary) page. It would be extraordinarily useful to just set the "print when expression" to something like "$V{page_number} < $V{total_pages}" or the equivalent.

The best solution I have so far is to simply draw white lines over top of the background lines in the summary band.... which is, of course, a horrible solution.

Does anyone have anything better?

Post Edited by jbedell at 02/05/2010 19:37
Link to comment
Share on other sites

  • 2 weeks later...

I've gotten around this problem by adding a column to my query that calculates the total number of rows in the recordset, then divide by the number of rows on a typical page.  This gives me a good estimate of the total number of pages.  I then use this field ($V{total_pages} = $F{cnt}.intValue() / 25) in my 'print when expression'  (ie: print such 'n such if total_pages >10)

The query is similar to the following:

with t2 as (SELECT 
count(acc.account_id) as cnt
    account acc where amt>10000) 

Select id, name, cnt from t2, account where amt >10000


Link to comment
Share on other sites

  • 1 year later...
  • 6 years later...


I know this thread is a bit (well, quite) old, but just in case someone is searching for this issue. The easiest way to get the number of total pages is by defining a variable with the next attributes:

Name: total_pages (or any other)Variable class: IntegerCalculation: highestReset type: reportIncrement type: pageVariable expression: ${PAGE_NUMBER}[/code]

I hope this may help.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...