JasperReports:默认值而不是'null'

lea*_*dro 13 jasper-reports

有没有办法为报表中的字段设置默认值?我在报告中有很多字符串字段,并希望它们在为空时显示"0,00".

med*_*pal 20

假设字段名称为"value",在"Text Field Expression"中写入:

($F{value} != null) ? $F{value} : "0.00"

  • 确保在iReport Designer 4.0.2中检查报告的脚本语言设置,此语法在Java中有效但在Groovy中无效 (5认同)

Chr*_*lma 5

如果需要,还可以在文本字段的属性中选择"空时为空".其他选项更灵活,但这样做非常快速和简单.