Jump to content
Changes to the Jaspersoft community edition download ×

How I do formulas?


2004 IR Help

Recommended Posts

By: Jose M. - jmlgonzalez

How I do formulas?

2005-05-11 12:59

HI.

 

I am stopped at this part, how I make a forumula in jasper, wich language script is used? can I make something like this?

 

if(account == "1") {

total = january;

}

 

how can I do those kinds of things...where to read about it..any example will be appreciated.

 

thanks an advance

 

 

 

 

By: Philippe Damerval - damerval

RE: How I do formulas?

2005-05-11 13:51

Jose,

 

You use straight java for the formulas. Input an expression that evaluates to a result of the same type as that expected by the field. Example:

If the field is type INTEGER and you want to insert the value 0:

new Integer(0)

I don't think you can have control structures but I may be wrong. Experiment by using the jasper samples to compile a report template into java code, and see what you can do. Personally, I prefer to encapsulate complex functions in a separate class that I then add to the classpath. It keeps things clean.

HTH

 

 

 

 

By: treurnicht - treurnicht

RE: How I do formulas?

2005-05-18 08:06

Jose,

 

The 'If ... then... else' statement will look like something this:

 

$F{account} == null ? new Double(0) : $F{account}

 

 

? - then

: - else

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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