子报表不会在主报表中显示(Jasperreports)

时间:2017-05-15 11:50:40

标签: report subreport subreports

我对Jasperreports很新,实际上我试图通过我的Mainreport显示子报告。当我单独运行它们时,它们都正常工作,但是当我尝试从托盘拖放Supreport并按照向导时,当我运行Mainreport时子报告不会显示。我试着找出问题,因为一个星期,但没有什么对我有用。

这是Mainreport XML:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0  -->
<!-- 2017-05-15T13:46:24 -->
<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="Report_1" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2f6e4db4-9f8f-4ffe-9759-6e1fd142f492">
    <property name="template.type" value="columnar"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="src/dataset1.xml"/>
    <property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
    <style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50" isBold="false"/>
    <style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false"/>
    <style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
    <style name="Detail" mode="Transparent" fontName="Times New Roman"/>
    <style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
        <conditionalStyle>
            <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
            <style mode="Opaque" backcolor="#F0EFEF"/>
        </conditionalStyle>
    </style>
    <subDataset name="Dataset1" uuid="bcf9a7c3-f040-47c7-b8b0-ffdf33b6fd91">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="src/dataset1.xml"/>
        <queryString>
            <![CDATA[]]>
        </queryString>
    </subDataset>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="reportName" class="java.lang.String">
        <fieldDescription><![CDATA[reportName]]></fieldDescription>
    </field>
    <field name="workdirectory" class="java.lang.String">
        <fieldDescription><![CDATA[workdirectory]]></fieldDescription>
    </field>
    <field name="konectorStatus" class="java.lang.String">
        <fieldDescription><![CDATA[konectorStatus]]></fieldDescription>
    </field>
    <field name="connectionStatus" class="java.lang.String">
        <fieldDescription><![CDATA[connectionStatus]]></fieldDescription>
    </field>
    <field name="stuckedCard" class="java.lang.String">
        <fieldDescription><![CDATA[stuckedCard]]></fieldDescription>
    </field>
    <field name="description" class="java.lang.String">
        <fieldDescription><![CDATA[description]]></fieldDescription>
    </field>
    <field name="testSteps" class="java.util.List">
        <fieldDescription><![CDATA[testSteps]]></fieldDescription>
    </field>
    <field name="shortDescription" class="java.lang.String">
        <fieldDescription><![CDATA[shortDescription]]></fieldDescription>
    </field>
    <field name="testResult" class="java.lang.String">
        <fieldDescription><![CDATA[testResult]]></fieldDescription>
    </field>
    <field name="class" class="java.lang.Class">
        <fieldDescription><![CDATA[class]]></fieldDescription>
    </field>
    <field name="authentication" class="java.lang.String">
        <fieldDescription><![CDATA[authentication]]></fieldDescription>
    </field>
    <pageHeader>
        <band height="81" splitType="Stretch">
            <line>
                <reportElement positionType="FixRelativeToBottom" x="0" y="70" width="551" height="1" uuid="dee835ad-ce13-4185-a455-2fc7cd2599d3"/>
            </line>
            <staticText>
                <reportElement style="Title" x="0" y="0" width="400" height="30" uuid="ca49ecc2-99c4-466b-93f0-1e91dc52bb72"/>
                <textElement>
                    <font size="16" isBold="false"/>
                </textElement>
                <text><![CDATA[Konnektorsimmulator Testfall Protokoll: ]]></text>
            </staticText>
            <image>
                <reportElement x="400" y="-5" width="153" height="65" uuid="4846b814-11f5-4b15-8c3b-edf1de2288a1"/>
                <imageExpression><![CDATA["/home/r4ff1/Dropbox/Arbeit/image.2UJ5YY.png"]]></imageExpression>
            </image>
            <textField>
                <reportElement x="0" y="30" width="553" height="30" uuid="b457f83a-3553-49a9-9cec-fc01637f5192"/>
                <textElement>
                    <font size="14" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{reportName}]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="468" splitType="Stretch">
            <textField>
                <reportElement x="100" y="7" width="453" height="30" uuid="8f7f0d01-07c8-41ae-af38-c6176d26bde1"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{reportName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="7" width="100" height="30" uuid="8336a307-e230-47e7-b1e7-a7c087dd67b5"/>
                <text><![CDATA[Name]]></text>
            </staticText>
            <textField>
                <reportElement x="100" y="37" width="453" height="33" uuid="bebc9514-dc72-4da9-84fd-bdb22e82bec0"/>
                <textFieldExpression><![CDATA[$F{shortDescription}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="2" y="37" width="100" height="30" uuid="7fec7ae1-18d5-4ae5-87d0-bbc3ac0f5828"/>
                <text><![CDATA[Kurzbeschreibung:]]></text>
            </staticText>
            <textField>
                <reportElement x="102" y="70" width="449" height="40" uuid="822b3688-6187-4bb9-95fd-14fb63be4dbe"/>
                <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="2" y="70" width="100" height="30" uuid="4bf8f337-b139-424c-a90e-3340688edace"/>
                <text><![CDATA[Beschreibung:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="121" width="100" height="30" uuid="21780a8f-dd43-47b3-aa45-d1a54f0641ce"/>
                <text><![CDATA[Eingangsdaten: ]]></text>
            </staticText>
            <textField>
                <reportElement x="200" y="120" width="353" height="31" uuid="658e2f24-3dd0-4f3b-8eda-a252ba28b01f"/>
                <textFieldExpression><![CDATA[$F{konectorStatus}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="100" y="120" width="100" height="30" uuid="f6406ac6-26cf-40da-8252-41453c65d981"/>
                <text><![CDATA[Konnektor Status: ]]></text>
            </staticText>
            <textField>
                <reportElement x="200" y="150" width="351" height="30" uuid="f70adee8-c72a-40d6-a098-4d0238e05bb2"/>
                <textFieldExpression><![CDATA[$F{connectionStatus}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="100" y="150" width="100" height="30" uuid="11dd9b77-4c93-4511-b921-ccce6e909d9e"/>
                <text><![CDATA[Verbindungsstatus: ]]></text>
            </staticText>
            <textField>
                <reportElement x="200" y="180" width="351" height="30" uuid="a7797ecd-5f75-4cb2-bb28-0b3f64013e14"/>
                <textFieldExpression><![CDATA[$F{authentication}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="100" y="180" width="100" height="30" uuid="eebc28e8-2029-4022-9cb0-8e77f858528c"/>
                <text><![CDATA[Authentifizierung: ]]></text>
            </staticText>
            <textField>
                <reportElement x="200" y="210" width="351" height="30" uuid="b0918e89-10fb-4874-9d23-002921d43ae0"/>
                <textFieldExpression><![CDATA[$F{workdirectory}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="100" y="210" width="100" height="30" uuid="d2ad59b8-5a55-499d-96d7-31b8cc8d2c63"/>
                <text><![CDATA[Dienstverzeichnis]]></text>
            </staticText>
            <textField>
                <reportElement x="390" y="240" width="161" height="30" uuid="28604659-6643-4db1-ba85-f59d4a456fd0"/>
                <textFieldExpression><![CDATA[$F{stuckedCard}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="102" y="240" width="288" height="30" uuid="158c9fe5-035b-41ea-80ac-7024f427861f"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Gesteckte Karten(Mandat > Terminal < Karte): ]]></text>
            </staticText>
            <line>
                <reportElement positionType="FixRelativeToBottom" x="2" y="280" width="551" height="1" uuid="49e79677-a0a1-4116-bc6c-b975aff6e535"/>
            </line>
            <staticText>
                <reportElement x="0" y="290" width="278" height="20" uuid="06dc0bc1-cd12-443b-a022-787e42319171"/>
                <textElement>
                    <font size="14" isBold="true"/>
                </textElement>
                <text><![CDATA[Schritt1: Karte Stecken
]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="310" width="551" height="40" uuid="d7663160-f2c1-4340-ae38-d5a10405a343"/>
                <text><![CDATA[Das Primärsystem führt beim ersten Stecken der Karte im Quartal automatisch eine online-Prüfung und Aktualisierung der eGK durch.]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="350" width="288" height="30" uuid="9c4d4fe2-f29f-49c2-ae5a-9ee11aa32f06"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Gesteckte Karten(Mandat > Terminal < Karte): ]]></text>
            </staticText>
            <textField>
                <reportElement x="290" y="350" width="263" height="30" uuid="374ced41-210a-46c8-90ad-4462f3dd0f40"/>
                <textFieldExpression><![CDATA[$F{stuckedCard}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="380" width="330" height="20" uuid="d3e9af6d-ac4e-4e28-b31d-79a4372017ec"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Prüfungsergebnis zu Schritt: ]]></text>
            </staticText>
            <textField>
                <reportElement x="80" y="401" width="435" height="67" uuid="6c1ff3e6-e67d-40b4-b92f-235b2b5ecb4d"/>
                <textFieldExpression><![CDATA[$F{testResult}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="400" width="100" height="30" uuid="a6c8dbc1-30b9-4b70-be48-993e27dc59c8"/>
                <text><![CDATA[Testergebnise: ]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="430" width="100" height="30" uuid="0cc928fa-e11a-4842-9fdf-1bdbd245ae9a"/>
                <text><![CDATA[testSteps]]></text>
            </staticText>
            <textField>
                <reportElement x="80" y="430" width="467" height="30" uuid="02395e47-6859-4b19-b1a7-75bb4e8fcc7b"/>
                <textFieldExpression><![CDATA[$F{testSteps}]]></textFieldExpression>
            </textField>
            <line>
                <reportElement positionType="FixRelativeToBottom" x="1" y="467" width="551" height="1" uuid="5cfaaf0b-22ea-4406-aef0-7f1a8551bcde"/>
            </line>
            <line>
                <reportElement positionType="FixRelativeToBottom" x="10" y="467" width="551" height="1" uuid="a4306707-5834-428b-a540-f46b52f43c28"/>
            </line>
        </band>
        <band height="468">
            <subreport overflowType="NoStretch">
                <reportElement key="" x="30" y="40" width="450" height="222" uuid="123d247f-df6b-418e-802e-4d09eacccbea"/>
                <subreportParameter name="Name ">
                    <subreportParameterExpression><![CDATA[$F{reportName}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["Subreport1.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <columnFooter>
        <band height="253" splitType="Stretch">
            <frame>
                <reportElement mode="Opaque" x="-20" y="240" width="555" height="13" forecolor="#D0B48E" backcolor="#9DB1B8" uuid="bfdca178-800d-445c-9a31-bb616a00e8ce"/>
                <textField evaluationTime="Report">
                    <reportElement style="Column header" x="513" y="0" width="40" height="13" forecolor="#FFFFFF" uuid="2fba0f87-635e-476d-858f-d102b26146fe"/>
                    <textElement verticalAlignment="Middle">
                        <font size="10" isBold="false"/>
                    </textElement>
                    <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement style="Column header" mode="Transparent" x="433" y="0" width="80" height="13" forecolor="#FFFFFF" uuid="e454d23d-bcfc-4c79-a399-0ef520a3150a"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font size="10" isBold="false"/>
                    </textElement>
                    <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
                </textField>
                <textField pattern="EEEEE dd MMMMM yyyy">
                    <reportElement style="Column header" x="2" y="0" width="197" height="13" forecolor="#FFFFFF" uuid="14d8de1e-8695-4078-a67f-0e69172574d5"/>
                    <textElement verticalAlignment="Middle">
                        <font size="10" isBold="false"/>
                    </textElement>
                    <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </columnFooter>
    <summary>
        <band height="802" splitType="Stretch">
            <subreport overflowType="NoStretch">
                <reportElement key="" style="Row" stretchType="ElementGroupBottom" x="30" y="40" width="450" height="222" uuid="90cb3729-2abe-4b9a-b5c7-541063f99b74"/>
                <subreportParameter name="Name ">
                    <subreportParameterExpression><![CDATA[$F{reportName}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["Subreport1.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </summary>
</jasperReport>

这是Supreport XML:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0  -->
<!-- 2017-05-15T13:48:15 -->
<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="Subreport1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Error" uuid="13acf49e-4913-4d1b-bccc-113817ad15d1">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="src/dataset1.xml"/>
    <style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false"/>
    <style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false"/>
    <style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
    <style name="Detail" mode="Transparent" fontName="Times New Roman"/>
    <style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
        <conditionalStyle>
            <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
            <style mode="Opaque" backcolor="#F0EFEF"/>
        </conditionalStyle>
    </style>
    <parameter name="Name" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="reportName" class="java.lang.String">
        <fieldDescription><![CDATA[reportName]]></fieldDescription>
    </field>
    <field name="workdirectory" class="java.lang.String">
        <fieldDescription><![CDATA[workdirectory]]></fieldDescription>
    </field>
    <field name="konectorStatus" class="java.lang.String">
        <fieldDescription><![CDATA[konectorStatus]]></fieldDescription>
    </field>
    <field name="connectionStatus" class="java.lang.String">
        <fieldDescription><![CDATA[connectionStatus]]></fieldDescription>
    </field>
    <field name="stuckedCard" class="java.lang.String">
        <fieldDescription><![CDATA[stuckedCard]]></fieldDescription>
    </field>
    <field name="description" class="java.lang.String">
        <fieldDescription><![CDATA[description]]></fieldDescription>
    </field>
    <field name="testSteps" class="java.util.List">
        <fieldDescription><![CDATA[testSteps]]></fieldDescription>
    </field>
    <field name="shortDescription" class="java.lang.String">
        <fieldDescription><![CDATA[shortDescription]]></fieldDescription>
    </field>
    <field name="testResult" class="java.lang.String">
        <fieldDescription><![CDATA[testResult]]></fieldDescription>
    </field>
    <field name="class" class="java.lang.Class">
        <fieldDescription><![CDATA[class]]></fieldDescription>
    </field>
    <field name="authentication" class="java.lang.String">
        <fieldDescription><![CDATA[authentication]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <detail>
        <band height="352">
            <line>
                <reportElement positionType="FixRelativeToBottom" x="-20" y="110" width="551" height="1" uuid="b7dd4853-cf98-4e96-8388-f0ba3269ef57"/>
            </line>
            <line>
                <reportElement positionType="FixRelativeToBottom" x="-20" y="211" width="551" height="1" uuid="dbabfe43-16ab-4c4f-9c86-73519692523a"/>
            </line>
            <staticText>
                <reportElement x="0" y="20" width="288" height="30" uuid="6906ae91-f112-4073-ae81-9b27dcc2b72b"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Gesteckte Karten(Mandat > Terminal < Karte): ]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="0" width="278" height="20" uuid="42a1543f-f2ac-4a42-9331-b3eca5690b9c"/>
                <textElement>
                    <font size="14" isBold="true"/>
                </textElement>
                <text><![CDATA[Schritt1: Karte Stecken
]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="80" width="180" height="20" uuid="ff671021-bef7-4cfa-b925-573a21971feb"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Prüfungsergebnis zu Schritt: ]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="178" width="100" height="30" uuid="84495cdb-5498-4622-ac32-082b8c142740"/>
                <text><![CDATA[testSteps]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="110" width="100" height="30" uuid="67ae3d16-c288-4809-807a-2b5e0a0e474d"/>
                <text><![CDATA[Testergebnise: ]]></text>
            </staticText>
            <textField>
                <reportElement x="80" y="110" width="465" height="68" uuid="8cee8a00-83f5-49da-aff4-afc566f853fa"/>
                <textFieldExpression><![CDATA[$F{testResult}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="80" y="182" width="465" height="30" uuid="6d909ecc-2828-40af-a40f-81a3d994db0c"/>
                <textFieldExpression><![CDATA[$F{testSteps}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

我希望有人可以帮助我.... 问候:拉斐拉

1 个答案:

答案 0 :(得分:1)

您正在使用XML-File作为两个报告的数据源。要使子报表显示数据,您必须通过数据源表达式而不是连接表达式为其提供准确的数据源。子报表未在文件系统上找到xml文件。

转到子报表属性并清空“连接表达式”字段。然后用

填充数据源表达式
((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("//")

您的XML文件似乎有一个空查询字符串,因此不需要xpath查询字符串。此解决方案适用于 Jasperstudio 6.x。

另一个解决方案是使用参数按钮将$ P {XML_DATA_DOCUMENT}参数传递给supreport。