How to use the same datasource twice in JasperReports/iReport

无人久伴 提交于 2019-12-04 03:10:32

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

The suggested workarounds were:

  • implement a custom query executer to retrieve data from a cached datasource
  • generate a rewindable datasource based on the retrieved result set

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

An alternative solution, cloning the dataset:

http://code.google.com/p/cloning/

Cloner cloner=new Cloner();

ArrayList clone = cloner.deepClone(getSomeArrayList());

final JRDataSource ds = new JRBeanCollectionDataSource(AnotherBean);

HashMap parameters = new HashMap();

parameters.put("PARAM_A", new JRBeanCollectionDataSource(getSomeArrayList()));

parameters.put("PARAM_B", new JRBeanCollectionDataSource(clone));

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!