使用 JasperReports,如何使用子数据集中的单行和单列结果填充文本字段?

发布于 2024-12-11 02:47:39 字数 469 浏览 0 评论 0原文

通常,对于报告,您有一个查询会返回大量数据,这些数据主要打印在详细信息区域中。我见过的报告编写工具都是针对此类报告的。

我发现自己正在编写一些摘要报告,其中不只是一个带有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡墨 2024-12-18 02:47:39

您可以使用子数据集来实现此目的。
阅读这篇关于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文