Please or Register to create posts and topics.

How to implement conditional formatting/conditional style in JasperSoft Studio 8.2?

Hi out there,
today's problem is: In an d Excel output, I want to format entire rows depending on the value of the field in one column. The field contains only values like 0, 1, 2,3, 4,6, 7 etc. Field type is either BigDecimal. It might be also converted to a string in SQL. Following ireport_ultimate_guide, I have created a conditional style as a "subs-style" of the style used for rows. However, the conditional expression

$F{DEBUG_EBENE_STRING}.toString().equals("0")

returns the following error in the report to which the style is applied:
"net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: Interpreted expression $F{DEBUG_EBENE_STRING}.toString().equals("0") is not a simple parameter/field/variable/resource message reference."

I have also tried other expressions such as

$F{DEBUG_EBENE}.compareTo(new java.math.BigDecimal(0)) == 0
and

$F{DEBUG_EBENE}.intValue() == 0
=> same error.
What can I do? Any hints are much appreciated.

Hello lekrof,

 

the condition expressions for conditional styles are very restricted when using them in a style template. When they are in the report itself, you can use any Boolean-type expression, but in a separate template, you can only use plain fields/variables etc. of type Boolean.

But you can work around this:

Create a variable named (e.g.) DEBUG_EBENE_ZERO of type Boolean defined by the expression

$F{DEBUG_EBENE}.compareTo(new java.math.BigDecimal(0)) == 0

and you can use $V{DEBUG_EBENE_ZERO} as the condition expression for your conditional style.

I hope this answers your question.

 

Regards,

Kilian

Thank you very much, Kilian, this did the trick! You've made my day 😎