我有一个报告,字段A和B来自我的数据库 . 在select语句中,有时A和B为空 .
问题是当我要求A - B的组和时,其中一个记录中有一个空值,总和为空 .
我该如何解决这个问题?
在jasper-reports变量表达式中,您可以使用ternary operator
($F{value1}!=null?$F{value1}:0)
with表示如果 value1 与 null 不同,则使用 value1 否则使用 0
value1
null
0
jrxml variable declaration example
<variable name="varWithTernary" class="java.lang.Double" calculation="Sum"> <variableExpression><![CDATA[($F{value1}!=null?$F{value1}:0)-($F{value2}!=null?$F{value2}:0)]]></variableExpression> </variable>
通过这些语句,您可以随意处理 null 值
1 回答
在jasper-reports变量表达式中,您可以使用ternary operator
with表示如果
value1
与null
不同,则使用value1
否则使用0
jrxml variable declaration example
通过这些语句,您可以随意处理
null
值