I'm new to JasperReports. I'm designing report using iReport. My requirement is I have two values (Fields) x,y to compare. If x < y then the data color for y should be changed to 'black' & if greater then data color of y should be changed to 'red'.
Please advice me as to how to proceed on this & where to validate.
I know this is an old question, but in I am assuming Jasper Reports has changed. You can now accomplish this with Conditional Styles.
In iReport you create a new Style and give it a name. You can put any default settings, such as font, color, text size, etc. in the style. Then you right click the Stlye and select Add Conditional Style. Then on the field or fields you want to apply it to you set the style to one you created.
So in your example I would set the Forecolor in the main stlye to be black, set the Condition Expression in the Conditional Style to be
$F{y} > $F{x}
and the Forecolor in the conditional Stlye to red. Then in the detail section where you have the y field placed set the style to the one we created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With