为什么在尝试打印波段页脚时会出现ABS表达式错误?

时间:2016-06-05 14:24:06

标签: jasper-reports

我试图只打印一个带状页脚,当两个数字彼此相差超过2.我不在乎哪一个如果差别就是那个差异超过2.我把表达式简单放入打印公式,但我收到错误。

在表达乐队页脚时,我的印刷品上有这个:

ABS($F{rop}-$V{Suggest_ROP}) >= 2.0

但是我收到了一个错误:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The operator >= is undefined for the argument type(s) Number, double
                value = ABS(((java.lang.Double)field_rop.getValue())-((java.lang.Integer)variable_Suggest_ROP.getValue())) >= 2.0; //$JR_EXPR_ID=15$
                        <------------------------------------------------------------------------------------------------------->
2. The operator >= is undefined for the argument type(s) Number, double
                value = ABS(((java.lang.Double)field_rop.getOldValue())-((java.lang.Integer)variable_Suggest_ROP.getOldValue())) >= 2.0; //$JR_EXPR_ID=15$
                        <------------------------------------------------------------------------------------------------------------->
3. The operator >= is undefined for the argument type(s) Number, double
                value = ABS(((java.lang.Double)field_rop.getValue())-((java.lang.Integer)variable_Suggest_ROP.getEstimatedValue())) >= 2.0; //$JR_EXPR_ID=15$
                        <---------------------------------------------------------------------------------------------------------------->
3 errors

at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:215)
at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:195)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.compileJasperDesign(ReportControler.java:439)

2 个答案:

答案 0 :(得分:1)

jasper报告函数ABS将返回java.lang.Number,这是一个抽象类,不支持任何算术或逻辑运算符,如+, - ,&lt;,&gt;,&lt; =

最简单的方法是从IntegerDoubleNumber查看类方法)中获取intValue()doubleValue()

ABS($F{rop}-$V{Suggest_ROP}).intValue() >= 2

答案 1 :(得分:0)

你可以用这个: new Boolean(ABS(new Double(“5”) - new Double(“4”))。intValue()&gt; 1)