3

I need your help in passing csv datasource to subReports .

I would highly appreciate your suggestion or solutions.

I am using iReport 5.0 professional version.
I have a very complex report and that report fetch data from multiple (approx 10) csv files.

I have created subReports for each section of the reports and each subReport is working fine as a indivisual Report.

But when i try to integrate all the subReports into a main Reports , then i am not able to pass datasource to the subReports.

In Main report, i created a parameter called CSVDS of type net.sf.jasperreports.engine.data.JRCsvDataSource with its default value as following: new net.sf.jasperreports.engine.data.JRCsvDataSource(new File("D:\\client\\data\\SR1.csv")) and in order to make sure that CSVDS is getting value from SR1.CVS , i added a textbod with following expression and it returned true

$P{CVSDS}.next() -- return true --which means that CSVDS gets populated from the data from SR1.csv

Further, i passed $P{CVSDS} as datasource to the subReport

<subreport>

<reportElement uuid="2f0d77ac-ce39-4487-8f31-0e15e03f5dfd" x="0" y="0" width="592" height="437"/>

<dataSourceExpression><![CDATA[$P{CSVDS}]]></dataSourceExpression>

<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "P1.jasper"]]></subreportExpression>

</subreport>

but the subReports was coming blank.

So, overall, i would like to know how can i pass csv datasource to subReports .

PS : I have tried almost all the solutions available on Stack overflow and Jasper community site but nothing worked for me.

4

1 回答 1

0

您需要将数据源表达式转换为正确的类型:

<subreport>

<reportElement uuid="2f0d77ac-ce39-4487-8f31-0e15e03f5dfd" x="0" y="0" width="592" height="437"/>

<dataSourceExpression><![CDATA[(net.sf.jasperreports.engine.data.JRCsvDataSource)$P{CSVDS}]]></dataSourceExpression>

<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "P1.jasper"]]></subreportExpression>

</subreport>
于 2014-09-04T06:08:53.780 回答