Jump to content
Changes to the Jaspersoft community edition download ×

Getting total #pages back to the program


Recommended Posts

By: Gestalt Solution - gestaltsolution

Getting total #pages back to the program

2003-07-02 19:25

Is there any way for the program to get the total number of pages printed when it generates a report? I need to store these statistics in a database for every report run.

Thanks.

 

 

By: Giulio Toffoli - gt78

RE: Getting total #pages back to the program

2003-07-03 01:15

 

You can with a trick. Add to your parameters map

passed to the fill method of jasper an Hashmap like this...

 

...

 

HashMap mymap = new HashMap();

parameters.put("MyHashMap",mymap);

 

....

 

Add in your report a parameter of type Object to recive this parameter (and name it MyHashMap).

Then create a variable of type Object with an expression like:

 

((java.util.HashMap)$P{MyHashMap}).put("MyReturnVal", $V{PAGE_NUMBER})

 

and resetType = "Report".

 

In this way, during report filling, jasperreports will put the number or report printed in you hashmap.

When the report is produced, you can retrive the number of page printed looking the value of...

 

(Integer)mymap.get("MyReturnVal");

 

Enjoy.

 

Giulio

Link to comment
Share on other sites

  • 5 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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...