Jump to content
JasperReports Library 7.0 is now available ×

subtract 2 numbers


jbegleyc

Recommended Posts

I am new to Jasper Reports and I am trying to put togather my first report. All I want to do is create a variable that subtracts 2 numbers:

 

$F{actual}-$F{forcast}

 

I can not seem to get this to work and can not find any examples. I keep getting a compile error:

 

'- operator invalid for java.lang.Double'

 

what could I be doing wrong here?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi,

 

Note that those should be valid Java expressions.

And in Java you cannot subtract Double ojects just like that (unless you are using JDK 1.5 syntax).

 

So, you either try:

 

new Double($F1{actual}.doubleValue() - $F2{}.doubleValue(forcast))

 

Or, you could learn how to config the JDT compiler for 1.5 compatibility here:

 

http://sourceforge.net/mailarchive/forum.php?thread_id=8390023&forum_id=7912

http://sourceforge.net/mailarchive/forum.php?thread_id=8391557&forum_id=7912

http://sourceforge.net/mailarchive/forum.php?thread_id=8401091&forum_id=7912

 

Another approach would be to use the Groovy compiler.

Check the supplied /demo/samples/groovy sample in our project distribution to see how simplified expression syntax could be used thanks to the Groovy language.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

Teodor,

 

Funny thing is I thought I had tried that before but it didn't work. It worked when I did it this time though so I must have typed something wrong.

 

Thank you for your help and I will check out the Groovy compiler when I get a chance.

 

Jeff

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