We are using the open source framework JasperReports to creating PDF reports.
One of my Team members wanted to create a MasterReport with a SubReport. The SubReport was nothing special, it included just static Text.The problem was, that the subreport was not rendered, it was always empty.
The problem was that the subreport need to have a data connection. Even you don’t need one. The solution is to include a empty DataSource like this:
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
The sub report definition in the master report looks like this:
<subreport> <reportElement x="0" y="246" width="504" height="100"/> <subreportParameter name="nameLabel"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportExpression> </subreport>
Thanks a bunch, you’re a life saver. I wonder why the hell they require a datasource if the sub report does not need one 😦
That’s a good question 🙂
You can also do the following:
– In the sub-report set the property `whenNoDataType=”NoDataSection”` on “.
– Put your static elements in the “ band.
This way you don’t have to set the `dataSourceExpression`.
Great! Good solution. I’m happy 🙂
still data is not display in subreport band