使用 JasperReports,如何使用子数据集中的单行和单列结果填充文本字段?
通常,对于报告,您有一个查询会返回大量数据,这些数据主要打印在详细信息区域中。我见过的报告编写工具都是针对此类报告的。
我发现自己正在编写一些摘要报告,其中不只是一个带有一个 where 子句的查询返回大量数据。在这些报告中,有许多具有不同 where 子句的查询,每个查询仅返回一个数字。该报告只有一页,每个数字都位于特定位置。
为了实现这一点,我正在做的是编写一个巨大的查询。首先,我选择一行,然后为我需要检索的每个附加数字提供一个带有其自己的 SQL 的左联接,该数字将成为结果中自己的列。我想摆脱这个巨大的疑问。另外,我刚刚遇到了 mysql 基本上抱怨查询太大的情况;这是关于嵌套太深的子查询的问题,但删除其中一个连接修复了它。
如果我可以使每个查询成为一个单独的子数据集并使用结果数字填充文本字段,那将会有很大帮助。
是否可以使用 scriptlet 来执行查询并将结果数字填充到变量中?
其他报告编写程序/库是否能让这变得更容易?
Typically with reports you have a single query that returns a lot of data that mostly gets printed in the detail area. The report-writing tools I've seen are geared towards this type of report.
I'm finding myself writing some summary reports where there isn't just one query with one where clause that returns a lot of data. On these reports there are many queries with different where clauses that each returns just one number. The report is just one page and each number goes in a specific spot.
What I'm doing to accomplish this is to write a query that is huge. First, I select one row then I have a left join with its own SQL for each additional number I need to retrieve, which becomes it's own column in the results. I would like to get away from having this huge query. Also, I just ran into a situation where mysql was basically complaining that the query was too large; it was something about too deeply-nested subqueries, but removing one of the joins fixed it.
It would help a lot if I could make each query a separate sub dataset and populate a textfield with the resulting number.
Could a scriptlet maybe be used to perform the query and populate the resulting number in a variable?
Do other report-writing programs/libraries make this easier?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用子数据集来实现此目的。
阅读这篇关于
Jasper subDataset
文章 >以及@GenericJon对此问题的回答。在某些情况下,
Jasper 子报表
也可以为您提供帮助。You can use sub datasets for this purpose.
Read this article about
Jasper subDataset
and the @GenericJon's answer on this question.The
Jasper subreport
can also help you in some cases.