如何在JasperReports中使用printWhenExpression [英] How to use printWhenExpression in JasperReports

查看:1370
本文介绍了如何在JasperReports中使用printWhenExpression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何使用JasperReports的 printWhenExpression 吗?

Can somebody tell me how to use the printWhenExpression of JasperReports?

推荐答案

你有相对于布尔值的错误吗?

Do you have an error relative to boolean ?

因为你需要使用布尔而不是基本类型。

Because you need to use Boolean instead of the primitive type.

所以:

$F{mesure} != "PH"
($F{userfd4}).equals("1") ? true : false 

会给无法从布尔值转换为布尔值

( $F{mesure}.startsWith("PH") ? Boolean.TRUE:Boolean.FALSE ) 
($F{userfd4}).equals("1") ? Boolean.TRUE : Boolean.FALSE  

是正确的。

另见示例

2015年11月更新(7年后)

Update Nov 2015 (7 years later)

Petter Friberg 指出在评论中


jasper report 6.0中,这不是必需的:

您可以返回 boolean Boolean 一个简单的表达式,如 $ F {fieldName} .equals(hello )将起作用。

In jasper report 6.0 this is not need:
You can return either boolean or Boolean a simple expression like $F{fieldName}.equals("hello") will work.

这篇关于如何在JasperReports中使用printWhenExpression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆