Variables and Expressions in JasperStudio


I have been working on making reports. I want to use variables for the sum of the values in the field. However, I am not able to understand how to set the appropriate expression for the variable and it is giving me the following error.

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $V{TotalFreights}
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $V{TotalFreights}
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillFixedBand(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnFooter(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageBreak(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBreak(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
at net.sf.jasperreports.engine.fill.BaseFillHandle$
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Float
at ORDERLIST1_1484312323037_882242.evaluate(ORDERLIST1_1484312323037_882242:315)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(
... 17 more


Please let me know from where I can learn how to use variables  and parameters in reports. I found most of the information on how to create them . I want to know where and how I can use them in the reports.

Thank you.

shivani133199699's picture
Joined: Dec 14 2016 - 4:55am
Last seen: 6 years 4 months ago

1 Answer:

You probably need to first study about programming in Java. The error message just states that you're trying to set Integer to a Float. To resolve this issue, you just need to make your variables and fields you're using in an expression to be of a same type. This isn't JasperReports issue but basic programming issue.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 12 months ago