如何在JasperReports/iReport中两次使用相同的数据源 [英] How to use the same datasource twice in JasperReports/iReport

查看:125
本文介绍了如何在JasperReports/iReport中两次使用相同的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出如何最好地制作图表,然后是代表相同数据集的表格.我需要克服摘要位于最底部的位置,因此打算使用子报表和表子报表.我正在一个细节区域内试验两个表和一个图表.

I'm trying to work out how best to do reports with a chart then a table representing the same dataset. I need to overcome the positioning of the summary is at the bottom, so intend to use subreports and table-subreports. I am experimenting with two tables and a chart in one detail band.

如果将datasourceexpression设置为$P{REPORT_DATA_SOURCE},则只有图表显示数据(可能是第一个子报表类型项),并且表为空.似乎数据只能被使用一次?

If I set the datasourceexpression for to $P{REPORT_DATA_SOURCE} only the chart displays data (presumably the first subreport type item) and the tables are empty. Seems the data can be consumed only once?

如果我使用数据集来查询数据库,它可以工作,但是它会执行三次查询,每个表/图表一次.这将是巨大的开销.

If I use a Dataset to query the database it works however it executes the Query three times, once for each table/chart. That will be a massive overhead.

很显然,我没有正确执行此操作,但是找不到使用同一数据集的示例不止一次.

Obviously I am not doing this right but I cannot find any examples of using the same dataset more than once.

推荐答案

没有简单的答案,因此我提出了功能请求

There is no simple answer so I have raised a feature request http://jasperforge.org/projects/jasperreports/tracker/view.php?id=5487

建议的解决方法是:

  • 实现自定义查询执行程序以从缓存的数据源中检索数据
  • 根据检索到的结果集生成可回退的数据源

感谢在jasperforge论坛上使用散打(sanda aka shertage)获得这些建议.

Thanks to sanda aka shertage on the jasperforge forum for these suggestions.

这篇关于如何在JasperReports/iReport中两次使用相同的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆