简体   繁体   English

将Jasper报告导出为pdf时出错

[英]Error when exporting jasper reports to pdf

I am getting the error below when I try to export jasper report to pdf. 尝试将jasper报告导出为pdf时出现以下错误。 Any help will be highly appreciated. 任何帮助将不胜感激。

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)

You must define the sums using double values instead of the Double and BigDecimal objects like: 您必须使用双精度值而不是Double和BigDecimal对象来定义总和,例如:

variable_TOTAL_CREDITS.getValue().doubleValue() + field_PREV_BAL.getValue().doubleValue()

And if the operation may exceed the limits of double type you can use: 如果操作可能超出double类型的限制,则可以使用:

new BigDecimal(variable_TOTAL_CREDITS.getValue().doubleValue())
    .add((java.math.BigDecimal)field_PREV_BAL.getValue())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM