JasperReports:封面页
我有一个 JasperReport,我想为此报告创建一个封面页。 封面页必须包含一些来自数据库的信息,例如公司名称等。 我试图使用子报告来做到这一点,但没有成功。 我创建了一个主报告,其中首先包含封面页作为子报告,然后 整个报告作为第二份子报告。我收到一份空报告。
我的第二次尝试是将封面页作为子报告放入主报告中,但是 这不太有效。
有任何提示如何执行此操作吗?
预先非常感谢。
I have a JasperReport and I want to create for this report a cover page.
The cover page must contain some information coming from the DB, like Company name, etc.
I am trying to do this using a subreport but I didn't succeed.
I've created a main report which contains first the cover page as a subreport and then
the whole report as a second subreport. I got an empty report.
My second try was to put inside the main report the cover page as a subreport but
this didn't work as well.
Any hint how to do this?
Thanks a lot in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Directory Discourse
使用 Jasper Reports 设置子报表并非易事。至少有两种方法可以告诉主报表在哪里可以找到子报表。
SUBREPORT_DIR
参数提供一个值。对于解决方案 1,在运行时确定主报告位置的绝对目录。然后,将子报表放置在主报表下的相关目录中。最后,告诉主报告包含子报告的子目录的绝对路径。
我没有使用解决方案2。
参数化主报表
考虑参数化主报表,而不是创建子报表。
如果您只有一份报告,但想要使用不同的徽标(以及公司名称、样式等),则可以使用参数来配置外观。
子报表用法
我发现当数据查询几乎相同但需要以稍微不同的方式对数据进行分组时创建子报表很有用。主报告包含所有常见内容(显示输入参数——以便可以重新创建报告、标题、公司名称、用户名、时间戳、页码等),而子报告则重点关注差异。通常,子报表会重叠,并且仅根据输入参数的值执行。
Directory Discourse
Setting up the subreport is not trivial using Jasper Reports. There are at least two ways to tell a master report where to find sub-reports.
SUBREPORT_DIR
parameter.For solution 1, determine the absolute directory of the master report location at run time. Then, place subreports in relative directories under the master report. Finally, tell the master report the absolute path to the subdirectory containing the subreports.
I have not used solution 2.
Parameterized Master
Consider parameterizing the master report, instead of creating subreports.
If you only have one report, but want to use a different logo (and company name, styling, and so forth), then use parameters to configure the look and feel.
Subreport Usage
I find it useful to create subreports when the queries for the data are nearly the same, but need to group the data in slightly different ways. The master report contains everything that is common (showing input parameters -- so that the report can be recreated, headings, company name, user name, time stamp, page number, and so on), and the subreports focus on the differences. Often, the subreports will overlap and only be executed depending on the value of an input parameter.
将它们添加到摘要区域,您甚至可以选择将其放在不同的页面上。
与您刚刚添加的子报告相比,您可以在他的摘要区域添加另一个子报告,
然后在他的身上再放一张,然后就可以了。您可以将无限的报告绑定在一起。
Add them to the summary band, you may even chose to have that on a different page.
Than on that subreport that you just added, at his summary band you can put another one,
and on his, another one and so you go. You can have infinite reports binded together.
我在标题带的末尾添加了一个中断。
这具有分页符的效果。
I added a break at the end of the title band.
This has the effect of a page break.
我可能误解了这个问题,因为接受的答案涉及阻止子报告,这是封面的完美解决方案(只需将其放在TITLE带中)。
子报表实际上是 JR 的杀手级功能。确实,它们并不简单,但无需对可用工具集进行任何调整或弯曲即可实现它们。
当数据集查询差异很大时,我会准确地使用它们......
I possibly misunderstood the question, because the accepted answer goes about discouraging subreports, which are the perfect solution for a cover (just put it in the TITLE band).
Subreports are actually the killer feature of JR. It's true they aren't simple, but they can be implemented without any tweaking nor bending of the available toolset.
And I use them EXACTLY when the dataset queries are widely different...
最近回答,但它可能会帮助另一个有点棘手的问题,
标题栏也将是您的封面页,您可以添加任何内容你想要
为每个页面添加您可以条件使用的组件(文本字段、图像、线条等)(int 打印表达式)
两页 jasper 报告的结帐示例
这是源代码的预览
Lately answer but It might help another one little bit tricky,
Title band will be your cover page as well you can add whatever you want
the component (TextField,Image,Line etc.) for every page you can use conditionaly(int print expression)
Checkout Example for with two page jasper report
This is preview ss for source code