当我尝试将jasper报告导出为pdf时,我收到以下错误。任何帮助将受到高度赞赏。
run:
Compiling Report Design ...
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The operator + is undefined for the argument type(s) Double, BigDecimal
value = ((java.lang.Double)variable_TOTAL_CREDITS.getValue()) + ((java.math.BigDecimal)field_PREV_BAL.getValue()); //$JR_EXPR_ID=23$
<------------------------------------------------------------------------------------------------------->
2. The operator + is undefined for the argument type(s) Double, BigDecimal
value = ((java.lang.Double)variable_TOTAL_CREDITS.getOldValue()) + ((java.math.BigDecimal)field_PREV_BAL.getOldValue()); //$JR_EXPR_ID=23$
<------------------------------------------------------------------------------------------------------------->
3. The operator + is undefined for the argument type(s) Double, BigDecimal
value = ((java.lang.Double)variable_TOTAL_CREDITS.getEstimatedValue()) + ((java.math.BigDecimal)field_PREV_BAL.getValue()); //$JR_EXPR_ID=23$
<---------------------------------------------------------------------------------------------------------------->
3 errors
.
Done compiling!!! ...
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:215)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:357)
at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:273)
at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:232)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:542)
at writetofileexample.WriteToFileExample.main(WriteToFileExample.java:175)
BUILD SUCCESSFUL (total time: 2 seconds)
答案 0 :(得分:1)
您必须使用double值而不是Double和BigDecimal对象来定义总和,例如:
variable_TOTAL_CREDITS.getValue().doubleValue() + field_PREV_BAL.getValue().doubleValue()
如果操作可能超出双重类型的限制,您可以使用:
new BigDecimal(variable_TOTAL_CREDITS.getValue().doubleValue())
.add((java.math.BigDecimal)field_PREV_BAL.getValue())