我正在尝试生成动态jasper xls报告。一切正常,但下面的代码总在页脚
report.addGlobalFooterVariable(column, DJCalculation.SUM, footerStyle);
失败,将显示最后一行值,而不是所有列的总和。 请帮忙。
编辑: 我尝试更改FLoat类型的计算列,并且如果我运行时遇到以下错误(StackTrace)
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{totalAmt}
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{totalAmt}
at net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(JREvaluator.java:268)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:356)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:607)
at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:208)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1392)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1366)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1085)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:582)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:121)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:983)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:244)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:215)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Float
at DJR_7807_1532334019068_679802.evaluateEstimated(DJR_7807_1532334019068_679802:949)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:342)
... 61 more
这是jrxml生成的textField,用于由dynamicjasper总量
<variable name="DJR_6701_variable-footer_global_totalAmt" class="java.lang.Float" resetType="Group" resetGroup="DJR_6701_global_column_0" calculation="Sum">
<variableExpression><![CDATA[$F{totalAmt}]]></variableExpression>
<initialValueExpression><![CDATA[new java.lang.Float("0")]]></initialValueExpression>
</variable>