R – Inclusion and exclusion of subreports (iReport-JasperReports)

ireportjasper-reports

I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.

Best Answer

you can in the master report get data from your data source that allows you to identify if the subreport should be included, then use the 'printWhenExpression' field on the subreport element to check that data.

I use this regularly - for example the printWhenExpression field may contain:

new Boolean($F{TOTAL_STATS}.intValue() != 0)

where TOTAL_STATS is from the master report's database query. If non-zero we show a subreport detailing some data.

Related Topic