Print When Expression in iReport

2019-03-31 06:37发布

问题:

I am trying to do a simple expression in iReport, but whatever I try seems has given me an error. It seems like such a simple thing to do, but whenever I try to do anything in Java it takes me about 20 tries to get it right.

All I'm trying to do is show a subreport when the value of an integer field is not zero. I am using the Print When Expression for the subreport control.

Here's a few (of the many) things that I've tried:

$F{count}!=0

$F{count}!=Integer(0)

!$F{count}.compareTo(0)

Obviously my Java sucks. Any help would be appreciated. Thanks.

回答1:

new Boolean($F{count}.intValue()!=0)

Glad that I could help.



回答2:

w00t! 35th time's a charm. I finally got the following expression to work. If anyone can tell me why, I would appreciate it.

new Boolean($F{count}.compareTo(new Integer(0))!=0)