pyreportjasper icon indicating copy to clipboard operation
pyreportjasper copied to clipboard

How to implementation subreports

Open arnaldocorreaxO opened this issue 1 year ago • 2 comments

How to implement subreports in pyreportjasper, do I have errors when trying to process the main report? image image

arnaldocorreaxO avatar Jan 27 '24 20:01 arnaldocorreaxO

There is more than one way to use a subreport. One of them is the way you tried, but instead of passing a *.jasper, you should pass a jrxml. Another way is by assigning only the name and extension of the subreport inside the jrxml, and the folder containing all the files that the report needs to pass as a parameter in resource.

Here is a link to an example using the last option. To continue using the current approach, use the jrxml of the subreport instead of the jasper: Example link

Example of how to use the second method mentioned

	<subreport>
		<reportElement x="0" y="0" width="555" height="20" uuid="e0dc40ad-4995-4e54-ae42-82a0a9a58126">
			<property name="local_mesure_unitheight" value="pixel"/>
			<property name="com.jaspersoft.studio.unit.height" value="px"/>
		</reportElement>
		<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/contacts/summary")]]></dataSourceExpression>
		<subreportExpression><![CDATA["header.jasper"]]></subreportExpression>
	</subreport>

Here you can see why we require a jrxml in the way you are currently using.

Code for one of the ways that deals with a subreport

jadsonbr avatar Jan 28 '24 01:01 jadsonbr

@arnaldocorreaxO We had an error processing subreports that was fixed in version 2.1.4.

jadsonbr avatar Apr 15 '24 12:04 jadsonbr