文本字段值中的 Jasper 报告 IF 条件
Jasper Report IF condition in Text Field Value
使用文本字段值编辑器,我将带有条件的文本添加到文本字段(注意 if 是使用 JasperSoft studio 的字段编辑器构建的,因此代码 IF(...) 是自动生成的,我只给出了值 "pippo" 和 "pluto")
"Some value" +IF(true,"pippo","pluto")
不过好像不行。从我的代码调用报告时出现此错误:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method IF(boolean, String, String) is undefined for the type
任何帮助将不胜感激
尝试使用 ternary
运算符代替 IF
,如下所示
"Some value" + (value == true ? "pippo" : "pluto")
希望这对您有所帮助。
您需要在构建文件中包含 jasperreports-functions。
例如:对于 gradle
implementation 'net.sf.jasperreports:jasperreports-functions:6.12.2'
使用文本字段值编辑器,我将带有条件的文本添加到文本字段(注意 if 是使用 JasperSoft studio 的字段编辑器构建的,因此代码 IF(...) 是自动生成的,我只给出了值 "pippo" 和 "pluto")
"Some value" +IF(true,"pippo","pluto")
不过好像不行。从我的代码调用报告时出现此错误:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method IF(boolean, String, String) is undefined for the type
任何帮助将不胜感激
尝试使用 ternary
运算符代替 IF
,如下所示
"Some value" + (value == true ? "pippo" : "pluto")
希望这对您有所帮助。
您需要在构建文件中包含 jasperreports-functions。 例如:对于 gradle
implementation 'net.sf.jasperreports:jasperreports-functions:6.12.2'