首页 文章

Jasper报告文本字段值中的IF条件

提问于
浏览
1

使用文本字段值编辑器我在文本字段中添加一个带有条件的文本(注意if是使用JasperSoft studio的字段编辑器构造的,因此代码IF(...)是自动生成的,我只给出了值“pippo”和“冥王星”)

"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

任何帮助将不胜感激

1 回答

  • 2

    尝试使用 ternary 运算符而不是 IF ,如下所示

    "Some value" + (value == true ? "pippo" : "pluto")
    

    希望这会帮助你 .

相关问题