Passing JRBeancollection datasourse to master repo

2019-08-26 12:38发布

I want to pass the JRBeancollection datadourse to main report and from main report to subreport.. I have included this subreport in summary section of master report.. please mention the steps i want to do in ireport including the inbuld parameters how to set.

2条回答
可以哭但决不认输i
2楼-- · 2019-08-26 13:25

Finally I have done it.

Actually datasource was not going in subreport. So I have changed the property of when no data to all sections, no data...

Then I have passed the collection variable where I have fetched the subreport records.

By using parameters.put("shape_data_all", allShape_Caliberation);

Then I have created a parameter in main report. And changed its class to java.Util.Collection.

Then in subreport property, connection type= Use a datasource expression

Data Source Expression new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{shape_data_all})

Then added the fields in the subreport same as I am having the bean properties.

Thank you.

查看更多
Emotional °昔
3楼-- · 2019-08-26 13:38

I'm not sure, but try this:

<subreport>
    <reportElement x="261" y="25" width="200" height="100"/>
    <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
    <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]]></subreportExpression>
</subreport>

Of course you have to use the "subreportExpression" as you are doing in your report, this is just a sample, the useful line for your problem is where the "dataSourceExpression" is placed.

查看更多
登录 后发表回答