Search code examples
jasper-reports

Jaspersoft ireport - Variable not found


I am working with my company's project. It uses Java Spring and Jaspersoft ireport 3.7.6 to print report.

I want to modify an exist report form (file jrxml). I want to sum a variable of 2 columns.

Data of these columns like

0/2/3/0

0/2/3/0=5

0/0/0/1

0/0/0/1=1

I have to calculate total of numbers which is behind '='.

I followed the solution in How to sum all values in a column in Jaspersoft iReport Designer?

I created a "GRAND_TOTAL" variable with caculation: "Sum", Class: "java.lang.Integer", resetType:"Report", incrementType:"none"

I added this condition to variableExpression

new Integer(($F{FullQty}.contains("=")) ? (Integer.valueOf($F{FullQty}.split("=")[1]).intValue() + Integer.valueOf($F{EmptyQty}.split("=")[1]).intValue() ) : (0))

When I print report, it shows error :

net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :

1. Variable not found : GRAND_TOTAL

Please help me!


Solution

  • I found the solution! My company's project use dynamic report. Therefore, I have to use fastReportBuilder to add variable in java code.