Can somebody tell me how to use the printWhenExpression
of JasperReports?
标签:
jasper-reports
相关问题
- Jasper: error opening input stream from url
- JasperReports Server parameter dependency
- is it possible print element only when its detail
- JasperReports CompileReport
- Print an arraylist content with JasperReports
相关文章
- How to set up jasper reports in spring with subrep
- Modularization of Jasper reports: Pass data source
- How to use jasperreports subreports with grails ja
- Current URL /web/guest/HTML generates exception: n
- SAX2 driver class not found
- Passing array data from PHP to JasperReports (with
- How to force image url in jasper report export to
- SubReport not shown
The other poster has done a good job of explaining the technical details of how to use it, so I'll try and explain the circumstances in which one might find it useful.
Basically, it allows you to show or hide the contents of a cell based on a boolean expression. For example, you might want to show a person's name only if that person is over 18, then in the name field, using a printwhenexpression like:
You can also use the static method "Boolean.valueOf(boolean b)". It does exactly the same logic as "($F{mesure}.startsWith("PH") ? Boolean.TRUE:Boolean.FALSE)" and good rule of thumb is don't recreate the wheel.
$P{mesure}.equals("200") should work without any additional details. It will print if the condition is true
Do you have an error relative to boolean ?
Because you need to use Boolean instead of the primitive type.
So:
would give
cannot cast from boolean to Boolean
.would be correct.
See also this example
Update Nov 2015 (7 years later)
Petter Friberg points out in the comments: