acesseonline / pyreportjasper

Python Reporting with JasperReports
https://pyreportjasper.readthedocs.io/en/latest/
GNU General Public License v3.0
126 stars 72 forks source link

How to implementation subreports #159

Open arnaldocorreaxO opened 7 months ago

arnaldocorreaxO commented 7 months ago

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

jadsonbr commented 7 months ago

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 commented 5 months ago

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