Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper report iterate over array list [duplicate]

how can I create report that will iterate over arraylist in detail section that is passed as parameter in Jasper report?

Is that even possible? I searched and I found soloution that you have to add ArrayList as datasource. How do I do that?

Regards

like image 892
Sobis Avatar asked Nov 02 '11 14:11

Sobis


1 Answers

You can create an SubReport an pass the ArrayList as DataSourceExpression:

        <subreport>
            ...
            <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{arrayList})]]></dataSourceExpression>
            <subreportExpression><![CDATA["subreport.jasper"]]></subreportExpression>
        </subreport>

Javadoc:

http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/data/JRBeanCollectionDataSource.html

like image 116
itshorty Avatar answered Nov 02 '22 04:11

itshorty