Jasper reports 无法将数据从主报表传递到报表中的子报表

Jasper reports 无法将数据从主报表传递到报表中的子报表,jasper-reports,subreport,Jasper Reports,Subreport,我试图使用表达式$p{report_data_SOURCE}将主报表可用的数据传递给子报表,但没有一个数据被传递给子报表。我知道,因为我已设置WhenNodeType=“AllSectionsNoDetail” 我在字段变量中读取的集合,我希望在子报表中重复使用相同的集合。我已经通过了这个链接,并尝试了所有建议的方法,但没有任何效果。 下面是我的主要报告jrxml。它只打印传递给子报表的子报表参数,没有子报表的详细信息部分 <?xml version="1.0" encoding="UT

我试图使用表达式$p{report_data_SOURCE}将主报表可用的数据传递给子报表,但没有一个数据被传递给子报表。我知道,因为我已设置WhenNodeType=“AllSectionsNoDetail”

我在字段变量中读取的集合,我希望在子报表中重复使用相同的集合。我已经通过了这个链接,并尝试了所有建议的方法,但没有任何效果。

下面是我的主要报告jrxml。它只打印传递给子报表的子报表参数,没有子报表的详细信息部分

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="statement" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" uuid="628d791a-f6fa-4391-9205-ea1764e19925">
    <property name="ireport.scriptlethandling" value="0"/>
    <property name="ireport.encoding" value="UTF-8"/>
    <import value="net.sf.jasperreports.engine.*"/>
    <import value="java.util.*"/>
    <import value="java.text.SimpleDateFormat"/>
    <import value="net.sf.jasperreports.engine.data.*"/>

    <field name="subpostingid" class="java.lang.String">
        <fieldDescription><![CDATA[subpostingid]]></fieldDescription>
    </field>
    <field name="tgtaccountnumber" class="java.lang.String">
        <fieldDescription><![CDATA[tgtaccountnumber]]></fieldDescription>
    </field>
    <field name="contraaccountname" class="java.lang.String">
        <fieldDescription><![CDATA[contraaccountname]]></fieldDescription>
    </field>
    <field name="debit" class="java.lang.String">
        <fieldDescription><![CDATA[debit]]></fieldDescription>
    </field>

    <title>
        <band height="367" splitType="Stretch">
            <textField isBlankWhenNull="false">
                <reportElement key="textField-9" x="0" y="10" width="324" height="30" uuid="6a6eb0ed-f5f4-4212-922e-527f7c8de372"/>
                <textFieldExpression><![CDATA[$R{fundsTransferApprovals}]]></textFieldExpression>
            </textField>            
        </band>
    </title>
    <columnHeader>
        <band height="53" splitType="Stretch">
            <textField isBlankWhenNull="false">
                <reportElement key="textField-15" x="0" y="0" width="324" height="27" uuid="ef3e213b-e902-4fd6-92ef-c072e7676648"/>
                <textFieldExpression><![CDATA[$R{beneficiaryDetails}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField-15" x="0" y="30" width="80" height="15" uuid="ef3e213b-e902-4fd6-92ef-c072e7676648"/>
                <textFieldExpression><![CDATA[$R{id}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField-16" x="80" y="30" width="200" height="15" uuid="5c1562ba-e316-4d69-bfb9-690aa65c8ccb"/>
                <textFieldExpression><![CDATA[$R{beneficiaryName}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField-17" x="280" y="30" width="140" height="15" uuid="f60d6a74-7ff1-4a6c-b5c4-17108b774e7f"/>
                <textFieldExpression><![CDATA[$R{beneficiaryAccount}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField-18" x="420" y="30" width="113" height="15" uuid="74f307a6-533a-4be8-a340-7d2d8b36b6aa"/>
                <textFieldExpression><![CDATA[$R{amount}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="33" splitType="Stretch">
            <printWhenExpression><![CDATA[java.lang.Boolean.valueOf($F{subpostingid} != null)]]></printWhenExpression>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="0" y="0" width="80" height="16" isRemoveLineWhenBlank="true" forecolor="#000000" uuid="b0dbca80-0f46-4e85-8e0f-551d143cad60"/>
                <textFieldExpression><![CDATA[$F{subpostingid}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="80" y="0" width="200" height="16" forecolor="#000000" uuid="d772ae5d-52dd-46b1-a60d-67b92a7153e1"/>
                <textFieldExpression><![CDATA[$F{contraaccountname}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="280" y="0" width="140" height="16" forecolor="#000000" uuid="cc617ff8-0649-4b20-bbbd-a082c29a5410"/>
                <textFieldExpression><![CDATA[$F{tgtaccountnumber}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="420" y="0" width="114" height="16" forecolor="#000000" uuid="bbf7210c-0979-49dc-b213-629b10e17f1d"/>
                <textFieldExpression><![CDATA[$F{debit}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="130" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="500" height="100" uuid="361dc76f-623e-4683-97df-252ccda05faa"/>
                <subreportParameter name="headingtext">
                    <subreportParameterExpression><![CDATA[$R{listOfSignatories}]]></subreportParameterExpression>
                </subreportParameter>               

                <dataSourceExpression><![CDATA[($P{REPORT_DATA_SOURCE})]]></dataSourceExpression>
                <subreportExpression><![CDATA["C:\\path\\approvals_subreport.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </summary>
</jasperReport>

您需要指定传递给主报表的数据源的类型。它实际上是一个xml数据源,所以应该指定什么以及在哪里?我也读过消耗品的概念,这就是这里的问题。数据已被消耗,没有更多的数据记录可与子报表共享?请检查我在帖子中的更新,添加更多详细信息请忽略我关于
报表\数据\源
参数为
的评论/回答。实际上,我考虑的是
REPORT\u CONNECTION
参数,对于任何非基于JDBC的连接,它都是
null
。你设法解决了你的问题吗?
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="approvals_subreport" pageWidth="500" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="500" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="89712d9b-194d-4499-875a-fe91d1a14964">
    <property name="ireport.scriptlethandling" value="0"/>
    <property name="ireport.encoding" value="UTF-8"/>
    <import value="net.sf.jasperreports.engine.*"/>
    <import value="java.util.*"/>
    <import value="java.text.SimpleDateFormat"/>
    <import value="net.sf.jasperreports.engine.data.*"/>
    <parameter name="headingtext" class="java.lang.String" isForPrompting="false"/>
    <parameter name="column1text" class="java.lang.String" isForPrompting="false"/>
    <parameter name="column2text" class="java.lang.String" isForPrompting="false"/>
    <parameter name="column3text" class="java.lang.String" isForPrompting="false"/>

    <field name="username" class="java.lang.String">
        <fieldDescription><![CDATA[username]]></fieldDescription>
    </field>
    <field name="loginid" class="java.lang.String">
        <fieldDescription><![CDATA[loginid]]></fieldDescription>
    </field>
    <field name="approvaltime" class="java.lang.String">
        <fieldDescription><![CDATA[approvaltime]]></fieldDescription>
    </field>
    <title>
        <band height="31" splitType="Stretch">
            <textField isBlankWhenNull="false">
                <reportElement key="textField-10" x="0" y="0" width="400" height="30" uuid="71c2ef41-1675-47cf-8f40-0eaec10d047b"/>
                <textFieldExpression><![CDATA[$P{headingtext}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="17" splitType="Stretch">
            <textField isBlankWhenNull="false">
                <reportElement key="textField-15" x="0" y="0" width="130" height="15" uuid="ef3e213b-e902-4fd6-92ef-c072e7676648"/>
                <textFieldExpression><![CDATA[$P{column1text}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField-16" x="130" y="0" width="230" height="15" uuid="5c1562ba-e316-4d69-bfb9-690aa65c8ccb"/>
                <textFieldExpression><![CDATA[$P{column2text}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField-17" x="360" y="0" width="140" height="15" uuid="f60d6a74-7ff1-4a6c-b5c4-17108b774e7f"/>
                <textFieldExpression><![CDATA[$P{column3text}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="50">
            <staticText>
                <reportElement x="26" y="10" width="100" height="30" uuid="173d8ef0-4a69-4661-b320-6a1e282be380"/>
                <text><![CDATA[text here]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>
ERROR p: default-threadpool; w: Idle 20200313 13:37:35 [ReportManager] ReportManager.generateReport : Errors were encountered when compiling report expressions class file:
1. The constructor JRXmlDataSource(Collection) is undefined
                value = new net.sf.jasperreports.engine.data.JRXmlDataSource(((java.util.Collection)field_approvals.getValue())); //$JR_EXPR_ID=45$