直接嵌入JasperReports中的子报表
我即将完成这项工作,我正在尝试将一个 jasper 子报表直接嵌入到另一个子报表的主报表 xml 中。 您可能认为这很容易,但我找不到这样做的单个示例。 每个人似乎都使用文件或资源或其他什么。 我有一个直接从字符串工作的报告,我希望它包含它的子报告。
任何人? 句法? 谢谢!
I am so close to having this work, I am trying to directly embed one jasper subreport into the main report xml of the other. You'd think this would be easy, but I can't find a single example on doing it. Everyone seems to use files or resources or whatever. I have one report working straight from a string and I want it to contain it's subreport.
Anyone? Syntax? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,使用 JasperReports 执行此操作的唯一方法是为子报表使用单独的 .jrxml 文件,并使用
subreport
命令将其包含在主报表中。对于任何嵌入式报告,您的另一个选择是使用子数据集,但据我所知,它们仅对图形有用。
听起来您可以控制围绕报告生成的代码,因此您可以提出一种简单的格式来在一个字符串中定义多个报告,然后让代码在运行时提取每个报告。
当我们需要处理单个文件但有 JasperReport 的子报表时,我们使用 Zip 文件,只需将主报表和所有必要的子报表压缩起来,然后在需要时将它们解压缩到临时目录中到(当然全部在代码中)
The only way I know of to do this with JasperReports is to use a separate .jrxml file for the subreport, and include it in the main report using the
subreport
command.Another option you have for any embedded reports is to use subdatasets, but as far as I know they're only useful for graphs.
As it sounds like you control the code surrounding the generation of the report, you could come up with a simple format to define multiple reports in the one string, and then have your code extract each report at runtime.
When we've needed to deal with a single file but have subreports for a JasperReport, we've used Zip files, and simply zipped up the main report and all it's necessary sub reports, and then unzipped them into a temporary directory when we need to (all in code of course)