Jump to content
We've recently updated our Privacy Statement, available here ×

Printing Alternate Colour Backgrounds On A Summary Only Report.


gregory.west

Recommended Posts

I have a report that is a summary only report.  This means the group footer lines are the only thing being printed.  The question comes up, how do I change the background colour for alternating groups.

Here is the solution I can up with:

Create a variable, in my case I used GROUP_PRINT Value Class Name:java.lang.Integer  Calculation is Sum.  Now here comes the magic, what you want to sum up are the number of first group detail records.  To do this I used the expression: ($V{Group1_COUNT}==1?1:0) which means when GROUP_COUNT = 1 return 1 for the sum, otherwise return 0.  Every group has to have one and only one first line.  The Initial Value Expression should be set to 0 (zero) Increment type is none, and Reset type is Report.

Now that will give you a variable GROUP_PRINT that will tell you the group number you are on.  From there create a frame in your group footer change the frames background colour to what you want and add the following to the Print When of the frame:($V{GROUP_PRINT} % 2) ==0.

There you go, group footers in alternating colour backgrounds.

Now for my harder question:   I have a clause in my footer for print when.  How do I tell if a footer was even printed for a particular group?

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Does anyone have any thoughts, I am even interested in out of the box ideas.   Right now I have a report that is supposed to be blue band, white band, blue band etc....    What I get is White, Blue, Blue, White, White, White, Blue, White, Blue, Blue... Depending on which summary lines are being printed.   Is there a way I can count up the summary lines that have been printed?

 

Greg

Link to comment
Share on other sites

Is there any way in Jasper Reports that I can tell / control in which order parameter fields are re-calculated?   This is a possible solution to the problem but I need a couple parameter fields to be recalculated in a very specific order.

Field1: Summary-Lines = Summer-lines + (Last-Group-ID != Current-Group-ID and Last-Group-Printed?1:0)

Field2: Last-Group-Printed = 'print when condition

Fiels3: Last-Group-ID = Current-Group-ID

The major trick here is these three fields MUST be recalculated in order,  Field1, then Field2, last Field3.    Is this possible?

Link to comment
Share on other sites

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