简体   繁体   English

JasperReports iReport中的摘要带

[英]Summary band in JasperReports iReport

I have a report built that is similar to an employee work log. 我有一个类似于员工工作日志的报告。 A group is created for each employee which contains an itemized list of all the work they have completed. 为每位员工创建一个组,其中包含他们已完成的所有工作的详细列表。 At the end of each employee, the total hours worked and amount earned is displayed in the Group Footer band. 在每位员工的末尾,“组尾”区域中将显示总工作时间和收入。 At the end of the entire report, the total hours and earnings of all employees is displayed. 在整个报告的末尾,将显示所有员工的总时数和收入。

I also have a separate report that is a summary of this same information, but without the details. 我还有一个单独的报告,该报告是此相同信息的摘要,但没有详细信息。 It is a report that lists an employee, hours worked, and total earnings on each row of a table. 该报告在表的每一行上列出了雇员,工作时间和总收入。 This is essentially the same information that is displayed in the Group Footer of the other report. 这基本上与另一个报表的“组尾”中显示的信息相同。

The same SQL command is used in both reports. 在两个报告中使用相同的SQL命令。 I would like to combine them into a single report that generates an itemized work log first, and then a detailed summary at the end. 我想将它们合并为一个报告,该报告首先生成一个逐项工作日志,然后在最后生成详细的摘要。 But I can't see a way to do this. 但是我看不到这样做的方法。

Actually, maybe I could turn both of my reports into subreports and create a master report that holds them both. 实际上,也许我可以将两个报告都转换为子报告并创建一个包含两个报告的主报告。 Is this the best approach? 这是最好的方法吗? Or is there a better solution? 还是有更好的解决方案?

You can certainly put them both into the same report. 您当然可以将它们放在同一份报告中。

You'll need to run the SQL query twice.† Putting your summary report into the summary band of your detailed report as a subreport will be the simplest solution. 您将需要运行两次SQL查询。†将摘要报告作为子报告放入详细报告的摘要带中将是最简单的解决方案。 You'll use the same SQL connection, then the subreport will run its own query (which just happens to be identical to the query in the main report). 您将使用相同的SQL连接,然后子报表将运行自己的查询(恰好与主报表中的查询相同)。

Alternative solutions include: 替代解决方案包括:

  • One main report that is nearly empty which holds two subreports. 一个几乎为空的主报表包含两个子报表。 This can be a good solution for complex reports. 对于复杂的报告,这可能是一个很好的解决方案。 But given your requirements, it creates a bit more work without any benefit. 但是根据您的要求,它会产生更多的工作,而没有任何好处。

  • Using a Table component (or List component) in the summary band rather than a subreport. 在摘要区域中使用表格组件(或列表组件),而不是子报表。 I generally prefer this. 我通常更喜欢这个。 If you didn't already have the two reports created, I would probably recommend this. 如果您尚未创建两个报告,那么我可能会建议您这样做。 But re-writing your report as a table component would again be additional work with no real benefit. 但是,将报表重新编写为表格组件将再次成为额外的工作,而没有真正的好处。

† That's not a fundamental requirement. †这不是基本要求。 If you decided that the SQL query is tremendously long-running and not further tune-able, then it would surely be possible to do everything in a single pass through the result set. 如果您确定SQL查询的运行时间非常长且无法进一步调整,那么肯定可以通过结果集一次完成所有操作。 It would just require extra cleverness to capture all of the information that you need in that single iteration and then display it in the summary. 只需要特别的聪明才能捕获一次迭代中所需的所有信息,然后将其显示在摘要中。 It would be significantly more work than the other variations. 这将比其他变体要多得多的工作。

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

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