2015-10-24 87 views
1

我有一個碧玉報告2子報告。當我從一個Java程序執行報告時,它顯示出來但是有空的子報告。這裏是我的報告:賈斯珀報告子報表不顯示數據

<?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="report3" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b0b596c0-43c5-4c85-8e81-e92b916f7bb5"> 
    <property name="ireport.zoom" value="1.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <style name="Title" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/> 
    <style name="SubTitle" forecolor="#666666" fontName="Arial" fontSize="18"/> 
    <style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/> 
    <style name="Detail" fontName="Arial" fontSize="12"/> 
    <parameter name="customer_id" class="java.lang.Integer"> 
     <defaultValueExpression><![CDATA[]]></defaultValueExpression> 
    </parameter> 
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> 
     <defaultValueExpression><![CDATA["reports/"]]></defaultValueExpression> 
    </parameter> 
    <parameter name="order_date" class="java.util.Date"> 
     <defaultValueExpression><![CDATA[]]></defaultValueExpression> 
    </parameter> 
    <parameter name="title" class="java.lang.String"/> 
    <queryString> 
     <![CDATA[SELECT 
    customer.`name` AS customer_name 
FROM 
    `customer` customer 
where id=$P{customer_id}]]> 
    </queryString> 
    <field name="customer_name" class="java.lang.String"/> 
    <background> 
     <band splitType="Stretch"/> 
    </background> 
    <title> 
     <band height="95" splitType="Stretch"> 
      <staticText> 
       <reportElement style="SubTitle" x="102" y="65" width="54" height="20" uuid="57dccf10-55f0-4d62-b391-c0a835ea062b"/> 
       <textElement textAlignment="Right"> 
        <font fontName="Serif" size="14"/> 
       </textElement> 
       <text><![CDATA[التاريخ:]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Column header" x="478" y="65" width="77" height="20" uuid="cc412a3e-0e4f-4868-9ea3-75c9e2f08bd3"/> 
       <textElement textAlignment="Right"> 
        <font fontName="Serif" size="14" isBold="true"/> 
       </textElement> 
       <text><![CDATA[المطلوب من:]]></text> 
      </staticText> 
      <textField> 
       <reportElement style="Detail" x="229" y="65" width="249" height="20" uuid="28bb50ef-8818-45d6-97c5-6608cc747060"/> 
       <textElement textAlignment="Right"> 
        <font fontName="Serif" size="14"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$F{customer_name}]]></textFieldExpression> 
      </textField> 
      <textField isBlankWhenNull="true"> 
       <reportElement x="3" y="65" width="100" height="20" uuid="32a97ac4-8aab-4167-99d6-1c3489f83db2"/> 
       <textElement textAlignment="Center" verticalAlignment="Middle"> 
        <font fontName="Serif" size="14"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$P{order_date}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement style="Title" x="142" y="16" width="265" height="33" uuid="dc9fed5e-e03c-475c-bd2b-1b351c318192"/> 
       <textElement textAlignment="Center" verticalAlignment="Middle"> 
        <font fontName="Serif" size="26" isBold="true"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$P{title}]]></textFieldExpression> 
      </textField> 
     </band> 
    </title> 
    <pageHeader> 
     <band splitType="Stretch"/> 
    </pageHeader> 
    <columnHeader> 
     <band splitType="Stretch"/> 
    </columnHeader> 
    <detail> 
     <band height="195" splitType="Stretch"> 
      <subreport> 
       <reportElement x="2" y="1" width="553" height="109" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" uuid="e9c0b556-6457-4dc8-9064-b9bf8a280490"/> 
       <subreportParameter name="title"> 
        <subreportParameterExpression><![CDATA[$P{title}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="REPORT_CONNECTION"> 
        <subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="order_date"> 
        <subreportParameterExpression><![CDATA[$P{order_date}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="cust_id"> 
        <subreportParameterExpression><![CDATA[$P{customer_id}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="customer_id"> 
        <subreportParameterExpression><![CDATA[$P{customer_id}]]></subreportParameterExpression> 
       </subreportParameter> 
       <connectionExpression><![CDATA[java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/metal?useUnicode=yes&characterEncoding=UTF-8","root", "")]]></connectionExpression> 
       <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "orders.jasper"]]></subreportExpression> 
      </subreport> 
      <subreport> 
       <reportElement positionType="Float" x="2" y="109" width="554" height="86" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" uuid="bca2d802-6eee-43c3-adb9-443cb2b11cd9"/> 
       <subreportParameter name="SUBREPORT_DIR"> 
        <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="title"> 
        <subreportParameterExpression><![CDATA[$P{title}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="order_date"> 
        <subreportParameterExpression><![CDATA[$P{order_date}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="cust_id"> 
        <subreportParameterExpression><![CDATA[$P{customer_id}]]></subreportParameterExpression> 
       </subreportParameter> 
       <subreportParameter name="customer_id"> 
        <subreportParameterExpression><![CDATA[$P{customer_id}]]></subreportParameterExpression> 
       </subreportParameter> 
       <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
       <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "order_additions.jasper"]]></subreportExpression> 
      </subreport> 
     </band> 
    </detail> 
    <columnFooter> 
     <band splitType="Stretch"/> 
    </columnFooter> 
    <pageFooter> 
     <band height="30" splitType="Stretch"> 
      <textField> 
       <reportElement style="Column header" x="435" y="9" width="80" height="20" uuid="aba41e81-e785-4bdf-bbaa-1d8c3be8b391"/> 
       <textElement textAlignment="Right"> 
        <font size="10" isBold="false"/> 
       </textElement> 
       <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression> 
      </textField> 
      <textField evaluationTime="Report"> 
       <reportElement style="Column header" x="515" y="9" width="40" height="20" uuid="ef8ba53a-7da2-4fb1-a438-d1b0e2eb3a25"/> 
       <textElement> 
        <font size="10" isBold="false"/> 
       </textElement> 
       <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> 
      </textField> 
      <textField pattern="EEEEE dd MMMMM yyyy"> 
       <reportElement style="Column header" x="2" y="9" width="197" height="20" uuid="84337f90-d94a-4f7a-a376-18bf89cc1de9"/> 
       <textElement> 
        <font size="10" isBold="false"/> 
       </textElement> 
       <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> 
      </textField> 
     </band> 
    </pageFooter> 
    <summary> 
     <band splitType="Stretch"/> 
    </summary> 
</jasperReport> 

我想我的報表不會得到父報表的連接。如何解決這個問題?

回答

1

,你有第二個報表是通過

<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 

所以你需要檢查

$P{SUBREPORT_DIR} + "order_additions.jasper", points to an actually report 

連接的正確方法,並在order_additions.jasper產生結果的查詢。