Passing JRBeancollection datasourse to master report and subreport

耗尽温柔 提交于 2019-12-11 18:43:22

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/11426174/passing-jrbeancollection-datasourse-to-master-report-and-subreport

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