How to pass ArrayList to JasperReports?

后端 未结 3 2154
臣服心动
臣服心动 2020-12-18 05:23

I\'m new to JasperReports. I want to pass ArrayList to subreport of subreport.

I have master report which contains one subreport1 and this

3条回答
  •  无人及你
    2020-12-18 05:32

    It's done by passing a collection data-source: new BeanCollectionDataSource(yourArrayList);

    And then to obtain the JasperPrint object:

    JasperPrint jasperPrint = 
          JasperFillManager.fillReport(jasperReport, params, dataSource);
    

    To pass to a subreport, you have two options:

    • If it is a subreport-per-row, simply have the array as a property of the bean. I.e. List where Something has a property of type List
    • If it is one for the whole report, pass it as a parameter (params above).

提交回复
热议问题