Jump to content
We've recently updated our Privacy Statement, available here ×

Newbie: calculation in a field & datasource with same tags


martham

Recommended Posts

1. Hi,  I am new to Jasper. My question is how can i perform a calculation of 2 fields in 1 . e.g. $F{rsp}  = $F{cost_price} + $F{tax}? do i do this in  the Text Field Expression?

2. I am using XML as my data source, 8 nodes have the same name tags, i want to use the 7th note to access the address from it, my template is displaying the wrong address from one of the nodes.

Please help. thanks.

<comp>
   <address> 12 This one gets
   <address> Displayed
<comp>
   <address>
   <address>
<comp>
   <address>34 Whereas I want
   <address>ThisOne
<comp>
   <address>
   <address>

 

 

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

1. You can do a calculation right within an expression of a textfield.  It could be simple math, or it could be other java or groovy statements, let's say you're mixing string and integer 'calculations':

<textFieldExpression><![CDATA[string.valueOf($F{FreightColumn}.intValue() * 100) + "-" + String.valueOf(($F{FreightColumn}.intValue() + 1) * 100)]]></textFieldExpression>

You can also use variables to do the calculation with different reset intervals, etc, then print the value of the variable in the textfieldexpression... or do some math with the variable if needed:
http://community.jaspersoft.com/wiki/variables

2. XML datasource sample is here - does this help - http://jasperreports.sourceforge.net/sample.reference/xmldatasource/index.html#xmldatasource

 

 

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