2015-06-11 3 views
0

Я получаю ошибку ниже, когда пытаюсь экспортировать отчет о яшме в pdf. Любая помощь будет высоко оценена.Ошибка при экспорте отчетов яшмы в 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) 

ответ

1

Вы должны определить суммы с использованием двойных значений вместо двойных и 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())