子报告在Detail band中重复出现 [英] The subreport repeats itself in Detail band

查看:486
本文介绍了子报告在Detail band中重复出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JasperReports的新手,基本上我想把一个子报告放在一个mainreport中

I am new to JasperReports, basically I want to put a subreport in a mainreport

问题是我把子报告放在了Detail带中,所以当我查询具有多个数据的数据库,当我将报告输出到pdf时,子报告将多次重复自身。我想要一个不会重复的报告,无论我连接的数据库中有多少数据

The problem is that I put the sub report in the Detail band, so when I query a database that has multiple data the subreport will always repeat itself multiple times when I output the report to a pdf. I want a report that does not repeat itself regardless of how many data I have in the database that i connect with

我已经搜索了互联网,解决方案是添加

I have searched the Internet and the solutions is to add

new Boolean($V{REPORT_COUNT}.intValue()==1)

打印时,子报表的表达式 属性,确实解决了我的部分问题由于现在我的子报表只打印一次,但在我的子报表显示后仍然留下一些空白页

in the print when expression attribute of the subreport, that does solve a part of my problem due to the fact that now my subreport only prints once but it still leaves some blank pages after my subreport is displayed

所以我认为它仍在重复,但只是没有由于我添加的表达式打印数据,人们说细节带的性质应该以这种方式工作,我不应该把子报告放在细节带中,但如果我把它放在其他一些乐队中我收到此错误:

So I assume it is still repeating itself but just doesn't print the data because of the expression that I added , people say that the nature of the detail band is supposed to work that way and that I shouldn't put the subreport in the detail band, but if I put it in some other band I get this error:

Error filling print... Subreport overflowed on a band that does not support overflow.

如果我有大量数据可能会占用更多数据,则会出现上述错误比一页。

The error above will happen if I have a lot of data to the extent that it may take up more than a page.

如何删除这些空白页面?如果我被要求不把它放在一个细节带里那么我该怎么办?或者有什么解决方案?

How do remove those blank pages? If I am ask to not put it in a detail band then what should I do? or what solution are there?

推荐答案

细节带的生成次数将与主体中的记录数一样多dataSet(由顶级查询填充)。

The Detail band will be generated as many times as the number of records you have in your main dataSet(populated by the top-level query).

如果要将子报表保留在详细信息区域中,顺便说一下,您可以执行以下操作之一这些东西:

If you want to keep the subreport in the Detail band, which is normal by the way, you can do one of these things:


  • 要么只有一个只返回一条记录的虚拟查询,所以Detail带只生成一次。然后,将报表连接传递给子报表。你可能已经这样做了。这样,您就可以独立于主报告运行查询。

  • 或保持报告原样并添加printWhen表达式( $ V {REPORT_COUNT} .intValue ()== 1 )直接在Detail band上,而不是在子报表上。请注意,这只是一个可能影响报告性能的丑陋黑客。您的主查询仍会返回大量您不使用的数据,因此您应该考虑其他选项。

  • either have a dummy query that returns only one record, so that the Detail band generates only once. Then, pass the report connection to your subreport. You may have done that already. This way you can run your query independently of the main report.
  • or leave the report as-is and add your printWhen expression ($V{REPORT_COUNT}.intValue()==1) directly on the Detail band, not on the subreport. Please note that this is just an ugly hack that may affect the report performance. Your main query still returns a lot of data that you don't use so you should consider the other options.

如果您可以移动从细节带出来的子报告,将其放在允许溢出的带中,如标题或摘要带。然后:

If you can move the subreport out of the Detail band, place it in a band that allows overflow like Title or Summary band. Then:


  • 让你的主数据集的查询为空,这样就不会产生细节带。

  • 设置whenNoDataType =报告级别的AllSectionsNoDetail(在< jasperReport> 标记中),以便除了详细信息之外的所有其他部分生成

  • 与上面第一个选项完全相同,将报表连接传递给子报表并从那里开始工作

  • have your main dataSet's query empty so that no Detail band gets generated
  • set whenNoDataType="AllSectionsNoDetail" at the report level(in the <jasperReport> tag) so that all the other sections except the Detail get generated
  • exactly as in the first option above, pass the report connection to your subreport and work from there

这篇关于子报告在Detail band中重复出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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