2013-01-09 3 views
2

XML 파일에 연결된 하위 보고서에 문제가 있습니다. 보고서를 실행하면 미리보기에 하위 보고서 데이터가 표시되지 않지만 하위 보고서 만 실행하면 데이터가 올바르게 표시됩니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?XML 파일 데이터 원본을 사용하는 하위 보고서가 작동하지 않습니다.

데이터 파일 :

<REPORTDATA> 
<HEAD> 
    <NUMBER>1</NUMBER> 
    <DESC>BLA BLA</DESC> 
    <DATE>2012.01.01</DATE> 
</HEAD> 
<GRID1> 
    <line id="1"> 
     <NUMBER>11</NUMBER> 
     <DESC>g11BLA BLA</DESC> 
     <DATE>2012.01.01</DATE> 
    </line> 
    <line id="2"> 
     <NUMBER>12</NUMBER> 
     <DESC>g12BLA BLA</DESC> 
     <DATE>2012.01.01</DATE> 
    </line> 
</GRID1> 
<GRID2> 
    <line id="1"> 
     <NUMBER>21</NUMBER> 
     <DESC>g21BLA BLA</DESC> 
     <DATE>2012.01.01</DATE> 
    </line> 
    <line id="2"> 
     <NUMBER>22</NUMBER> 
     <DESC>g22BLA BLA</DESC> 
     <DATE>2012.01.01</DATE> 
    </line> 
</GRID2> 

보고서 :

<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="reporttest" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6a9eed56-d1c3-46d8-9e16-4166c146b8a3"> 
<property name="ireport.zoom" value="1.0"/> 
<property name="ireport.x" value="0"/> 
<property name="ireport.y" value="0"/> 
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> 
    <defaultValueExpression><![CDATA["C:\\Users\\A2O\\Desktop\\"]]></defaultValueExpression> 
</parameter> 
<queryString language="xPath"> 
    <![CDATA[/REPORTDATA/HEAD]]> 
</queryString> 
<field name="NUMBER" class="java.lang.String"> 
    <fieldDescription><![CDATA[NUMBER]]></fieldDescription> 
</field> 
<field name="DESC" class="java.lang.String"> 
    <fieldDescription><![CDATA[DESC]]></fieldDescription> 
</field> 
<field name="DATE" class="java.lang.String"> 
    <fieldDescription><![CDATA[DATE]]></fieldDescription> 
</field> 
<background> 
    <band splitType="Stretch"/> 
</background> 
<title> 
    <band height="79" splitType="Stretch"> 
     <textField> 
      <reportElement uuid="bd7929b3-092d-44b9-b488-c0418fb57749" x="4" y="6" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{NUMBER}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="de902808-67e8-4b08-bd0b-c1d735409843" x="6" y="32" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="86d57bd0-01d3-4b1f-b9bb-0eb7cf2c19fc" x="5" y="56" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{DATE}]]></textFieldExpression> 
     </textField> 
    </band> 
</title> 
<pageHeader> 
    <band height="13" splitType="Stretch"/> 
</pageHeader> 
<columnHeader> 
    <band height="12" splitType="Stretch"/> 
</columnHeader> 
<detail> 
    <band height="26" splitType="Stretch"> 
     <staticText> 
      <reportElement uuid="819f4027-8ad0-46b4-b07c-c80234fe8411" x="12" y="0" width="100" height="20"/> 
      <textElement/> 
      <text><![CDATA[Static text]]></text> 
     </staticText> 
    </band> 
</detail> 
<columnFooter> 
    <band height="11" splitType="Stretch"/> 
</columnFooter> 
<pageFooter> 
    <band height="9" splitType="Stretch"/> 
</pageFooter> 
<summary> 
    <band height="42" splitType="Stretch"> 
     <subreport> 
      <reportElement uuid="4ab29d23-9ead-491e-8ca3-8f9790280026" x="0" y="0" width="555" height="42"/> 
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
      <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "reporttest_subreport1.jasper"]]></subreportExpression> 
     </subreport> 
    </band> 
</summary> 

하위 보고서 :

<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="reporttest_subreport1" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="ca109af7-4e08-405d-b43f-4062115c500e"> 
<property name="ireport.zoom" value="1.0"/> 
<property name="ireport.x" value="0"/> 
<property name="ireport.y" value="0"/> 
<queryString language="xPath"> 
    <![CDATA[/REPORTDATA/GRID1/line]]> 
</queryString> 
<field name="NUMBER" class="java.lang.String"> 
    <fieldDescription><![CDATA[NUMBER]]></fieldDescription> 
</field> 
<field name="DESC" class="java.lang.String"> 
    <fieldDescription><![CDATA[DESC]]></fieldDescription> 
</field> 
<field name="DATE" class="java.lang.String"> 
    <fieldDescription><![CDATA[DATE]]></fieldDescription> 
</field> 
<background> 
    <band splitType="Stretch"/> 
</background> 
<title> 
    <band splitType="Stretch"/> 
</title> 
<pageHeader> 
    <band height="36" splitType="Stretch"/> 
</pageHeader> 
<columnHeader> 
    <band height="69" splitType="Stretch"> 
     <staticText> 
      <reportElement uuid="867a24dd-6172-40ef-be33-f8e51fa21207" x="0" y="0" width="100" height="20"/> 
      <textElement/> 
      <text><![CDATA[Grid1 data:]]></text> 
     </staticText> 
     <staticText> 
      <reportElement uuid="0885dada-a149-4cb7-b82c-fdfa9847061d" x="32" y="49" width="100" height="20"/> 
      <textElement/> 
      <text><![CDATA[NUMBER]]></text> 
     </staticText> 
     <staticText> 
      <reportElement uuid="7261c001-6771-47dc-9749-5e6f64fb86df" x="159" y="49" width="100" height="20"/> 
      <textElement/> 
      <text><![CDATA[DESC]]></text> 
     </staticText> 
     <staticText> 
      <reportElement uuid="2b95c6fc-3fd9-4df1-89c6-5249173db3e1" x="287" y="49" width="100" height="20"/> 
      <textElement/> 
      <text><![CDATA[DATE]]></text> 
     </staticText> 
    </band> 
</columnHeader> 
<detail> 
    <band height="23" splitType="Stretch"> 
     <textField> 
      <reportElement uuid="becea2ba-40fd-4208-8191-c7475293ed5b" x="32" y="1" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{NUMBER}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="182efb3b-6a66-4634-be35-fe03e8a0cd45" x="159" y="0" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="bdb70a35-b4e6-4857-96c5-f607ee59bc07" x="287" y="0" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{DATE}]]></textFieldExpression> 
     </textField> 
    </band> 
</detail> 
<columnFooter> 
    <band height="15" splitType="Stretch"/> 
</columnFooter> 
<pageFooter> 
    <band height="6" splitType="Stretch"/> 
</pageFooter> 
<summary> 
    <band height="7" splitType="Stretch"/> 
</summary> 

답변

2

xml 파일을 데이터 소스로 사용하는 하위 보고서의 경우 하위 보고서의 데이터 소스를 지정해야합니다. 속성 당신은

  1. 연결 유형있는 모습이 필요합니다 :

((net.sf.jasperreports.engine.data :

  • 연결/데이터 소스 발현 데이터 소스 식을 사용하여 .JRXmlDataSource) $ P {REPORT_DATA_SOURCE}). subDataSource ("// YOUR_SUBREPORT_ENTITY").

  • 당신은

    <dataSourceExpression><![CDATA[ 
    
    ((net.sf.jasperreports.engine.data.JRXmlDataSource) 
    $P{REPORT_DATA_SOURCE}).subDataSource("//YOUR_SUBREPORT_ENTITY") ]]> 
    </dataSourceExpression> 
    
    +0

    고마워요이 비슷한 필요합니다. 이것은 효과가 있었다. – NeoRamza

    +0

    iam도 같은 문제가 있지만 하위 보고서를받지 못했을 때 다른 해결책이 있습니까? –

    +0

    ''// YOUR_SUBREPORT_ENTITY "'의 값은 무엇입니까? @ NeoRamza는 업데이트 된 작동중인 jrxml 스 니펫을 제공해 주시겠습니까? – Manu