将数据传递给子报表
这是主报告的片段。借助 net.sf.jasperreports.engine.data.JRBeanCollectionDataSource 构造函数将数据源传递给子报表
<field name="someFieldWithList" class="java.util.List"/>
<!-- ...... -->
<subreport>
<reportElement x="0" y="0" width="200" height="70"/>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<dataSourceExpression><![CDATA[net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{someFieldWithList})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]]></subreportExpression>
</subreport>