在JasperReports中进行比较 [英] doing comparison if else in JasperReports
问题描述
我想进行比较,例如:
if <field> == 0 then "-"
有人可以告诉我使用JasperReports的语法吗?
Can somebody tell me the syntax using JasperReports?
推荐答案
iReport(JasperReports)使用三元运营商。例如,考虑以下逻辑:
iReport (JasperReports) uses a Ternary operator. For example, consider the following logic:
IF boolean condition THEN
execute true code
ELSE
execute false code
END IF
使用三元运算符,这将成为:
Using a ternary operator, this becomes:
boolean condition ? execute true code : execute false code
使用带有以下表达式的变量时:
When using a variable with the following expression:
$F{column_value}.intValue() == 42 ? "Life, Universe, Everything" : "Naught"
然后变量的值将是Life,Universe ,Everythingif,且仅当 $ F {column_value}
的整数值等于42时。
Then the variable's value would be "Life, Universe, Everything" if, and only if, the integer value of $F{column_value}
is equal to 42.
当你必须有嵌套条件时,事情变得有点迟钝。对于这些,将嵌套条件放在括号中并单独行:
Where things get a little obtuse is when you have to have nested conditions. For these, put the nested conditions in parenthesis and on a separate line:
condition1 ?
(condition2 ? true_code2 : false_code2) :
false_code1
所以当你需要时做其中许多:
So when you need to do many of them:
condition1 ?
(condition2 ?
(condition3 ? true_code3 : false_code3) :
false_code2) :
(condition4 ? true_code4 : false_code4)
这篇关于在JasperReports中进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!