简体   繁体   English

Jasper Reports:子报表没有数据时不呈现主报表

[英]Jasper Reports: do not render main report when subreports have no data

Situation I have a report which consists of a header and four subreports in the detail area.情况我有一份报告,其中包含 header 和详细区域中的四个子报告。 The subreports get their data by querying a database.子报表通过查询数据库来获取数据。

Requirement If all the subreports have no data, then I would like the main report not to generate - similar to the property "When No Data" set to "No Pages".要求如果所有子报表都没有数据,那么我希望不生成主报表 - 类似于属性“无数据时”设置为“无页面”。

Problem Each subreport has the property "Remove Line When Blank" checked so each subreport will only print if it has data.问题每个子报表都选中了“空白时删除行”属性,因此每个子报表只有在有数据时才会打印。 However in the main report, the query text is "select 1 from dual" so that it will always print.然而,在主报告中,查询文本是“从双重中选择 1”,因此它将始终打印。 I want to change this to be dependent on the subreports, so that if all the subreports have no data, it will return nothing and therefore the whole report will not print due to "When No Data" being set to "No Pages".我想将其更改为依赖于子报表,这样如果所有子报表都没有数据,它将不返回任何内容,因此由于“无数据时”设置为“无页面”,整个报表将不会打印。

There should be a way to set the print when expression for you main report to check your subreports for data, and then only show the main report if at least 1 of them does.应该有一种方法可以为您的主报告设置 print when 表达式以检查您的子报告中的数据,然后仅在其中至少一个报告时才显示主报告。 Something like:就像是:

if (subreport1HasData || subreport2HasData || subreport3HasData || subreport4HasData)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM