简体   繁体   English

iReport中的子报表

[英]SubReports in iReport

Can I have many subreports for one report on my Java Project? Java项目中的一份报告可以有很多子报告吗?

I have a class that generates the main report and depending on which report the user chooses the subreport will be generated within the main report. 我有一个生成主报告的类,根据用户选择的子报告,将在主报告中生成该类。 But I do this on Java Classes, on iReport I only put the parameters. 但是我在Java类上执行此操作,在iReport上我只放置了参数。 So I have only one main report and many subreports that will inserted depending on which the user will choose. 因此,我只有一个主报表和许多子报表,这些报表将根据用户的选择进行插入。 Is that possible? 那可能吗?

A first approach might be using the printWhenExpression property on the sub/report element on your main report. 第一种方法可能是在主报表的sub / report元素上使用printWhenExpression属性。
In details: you should put all your sub-reports inside the main one, set one or some parameters which are passed from your Java code to the report, and set the above mentioned property to get this parameter/parameters value. 详细信息:您应该将所有子报表放在主报表中,设置一个或一些从Java代码传递到报表的参数,并设置上述属性以获取此参数/参数值。 Example: <printWhenExpression><![CDATA[new Boolean($F{CONDITION}.equals("N"))]]></printWhenExpression> This, inside a subreport element, ensures that it will be printed only if the CONDITION parameter (which has it's value set from your app) is equals to N. It could be an int, char and so on. 示例: <printWhenExpression><![CDATA[new Boolean($F{CONDITION}.equals("N"))]]></printWhenExpression>在子报表元素内,这确保仅在有条件时才打印参数(从您的应用中设置了值)等于N。它可以是int,char等。
Another option, to be considered if the whole structure changes from case to case, might be using DynamicReports (based on Jasper-Reports) 如果整个结构因情况而异,可以考虑使用另一个选项,即使用DynamicReports (基于Jasper-Reports)。

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

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