2016-04-06 66 views
0

我已經創建了報告,它獲取的名字和姓氏和發票ID的值,但是當我添加子報告時,其他值沒有得到它只是打印標題。請解決我的問題,並建議我。生成子報告詳細信息的問題?

它正在打印如下圖像。

主要報告代碼:

<?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="Usage Rport" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" > 
<property name="com.jasperassistant.designer.GridHeight" value="12"/> 
<property name="com.jasperassistant.designer.GridWidth" value="12"/> 
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/> 
<property name="com.jasperassistant.designer.Grid" value="false"/> 
<property name="ireport.zoom" value="1.0"/> 
<property name="ireport.x" value="0"/> 
<property name="ireport.y" value="0"/> 
<import value="org.joda.time.DateTime"/> 
<parameter name="invoice_id" class="java.lang.Integer"/> 
<parameter name="entity_id" class="java.lang.Integer"/> 
<parameter name="entityPhoneCountryCode" class="java.lang.String"/> 
<parameter name="entityPhoneAreaCode" class="java.lang.String"/> 
<parameter name="entityPhoneContry" class="java.lang.String"/> 
<parameter name="invoiceDate" class="java.lang.String"/> 
<parameter name="invoiceDueDate" class="java.lang.String"/> 
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> 
    <defaultValueExpression><![CDATA["D:\\Ravi Workspace\\Openbrm\\open-brm-openbrm-2.0\\descriptors\\reports\\usage\\"]]></defaultValueExpression> 
</parameter> 
<queryString> 
    <![CDATA[select co.first_name,co.last_name,b.id as user_id from swiss_cdr_event e join order_process o join base_user b on b.id=e.user_id and e.order_id = o.order_id join contact co on e.user_id=co.user_id where o.invoice_id=$P{invoice_id} and b.entity_id=$P{entity_id} order by e.call_start_date asc;]]> 
</queryString> 
<field name="first_name" class="java.lang.String"/> 
<field name="last_name" class="java.lang.String"/> 
<field name="user_id" class="java.lang.Integer"/> 
<title> 
    <band height="20"/> 
</title> 
<pageHeader> 
    <band height="111"> 
     <textField> 
      <reportElement x="5" y="13" width="200" height="15" /> 
      <textElement> 
       <font size="10" isBold="true"/> 
      </textElement> 
      <textFieldExpression><![CDATA[$F{first_name}+" " +$F{last_name}]]></textFieldExpression> 
     </textField> 
     <staticText> 
      <reportElement x="185" y="13" width="140" height="15" /> 
      <textElement textAlignment="Left"> 
       <font isBold="true"/> 
      </textElement> 
      <text><![CDATA[Rechnungs-Nr. ]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="368" y="13" width="100" height="15" /> 
      <textElement> 
       <font isBold="true"/> 
      </textElement> 
      <text><![CDATA[Jahr/Monat]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="379" y="28" width="52" height="15" /> 
      <textElement> 
       <font isBold="true"/> 
      </textElement> 
      <text><![CDATA[datiert]]></text> 
     </staticText> 
     <textField> 
      <reportElement x="252" y="13" width="100" height="15" /> 
      <textElement> 
       <font isBold="true"/> 
      </textElement> 
      <textFieldExpression class="java.lang.Integer"><![CDATA[$P{invoice_id}]]></textFieldExpression> 
     </textField> 
     <subreport> 
      <reportElement x="434" y="28" width="119" height="18" /> 
      <subreportParameter name="invoiceId"> 
       <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression> 
      </subreportParameter> 
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
      <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "run-details.jasper"]]></subreportExpression> 
     </subreport> 
     <subreport> 
      <reportElement x="435" y="9" width="161" height="15" /> 
      <subreportParameter name="invoiceId"> 
       <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression> 
      </subreportParameter> 
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
      <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "invoice-period-31.jasper"]]></subreportExpression> 
     </subreport> 
     <staticText> 
      <reportElement x="185" y="28" width="100" height="15" /> 
      <textElement> 
       <font isBold="true"/> 
      </textElement> 
      <text><![CDATA[Gesprächsnachweis]]></text> 
     </staticText> 
     <subreport> 
      <reportElement x="6" y="57" width="590" height="43" /> 
      <subreportParameter name="invoiceId"> 
       <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression> 
      </subreportParameter> 
      <subreportParameter name="entityId"> 
       <subreportParameterExpression><![CDATA[$P{entity_id}]]></subreportParameterExpression> 
      </subreportParameter> 
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
      <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "usage-31-de-details.jasper"]]></subreportExpression> 
     </subreport> 
    </band> 
</pageHeader> 
<pageFooter> 
    <band height="33"> 
     <textField> 
      <reportElement x="195" y="15" width="80" height="15" /> 
      <textElement textAlignment="Right"/> 
      <textFieldExpression><![CDATA["Seite "+$V{PAGE_NUMBER}+" von "]]></textFieldExpression> 
     </textField> 
     <textField evaluationTime="Report"> 
      <reportElement x="275" y="15" width="40" height="15" /> 
      <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> 
     </textField> 
    </band> 
</pageFooter> 
<lastPageFooter> 
    <band height="33"> 
     <textField> 
      <reportElement x="205" y="18" width="80" height="15" /> 
      <textElement textAlignment="Right"/> 
      <textFieldExpression><![CDATA["Seite "+$V{PAGE_NUMBER}+" von "]]></textFieldExpression> 
     </textField> 
     <textField evaluationTime="Report"> 
      <reportElement x="285" y="18" width="40" height="15" /> 
      <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> 
     </textField> 
    </band> 
</lastPageFooter> 
<summary> 
    <band height="20"/> 
</summary> 

子報表代碼:

<?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="Usage Rport" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" > 
<property name="com.jasperassistant.designer.GridHeight" value="12"/> 
<property name="com.jasperassistant.designer.GridWidth" value="12"/> 
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/> 
<property name="com.jasperassistant.designer.Grid" value="false"/> 
<import value="org.joda.time.DateTime"/> 
<parameter name="invoice_id" class="java.lang.Integer"/> 
<parameter name="entity_id" class="java.lang.Integer"/> 
<parameter name="entityCity" class="java.lang.String"/> 
<parameter name="customerCity" class="java.lang.String"/> 
<parameter name="entityPhoneCountryCode" class="java.lang.String"/> 
<parameter name="entityPhoneAreaCode" class="java.lang.String"/> 
<parameter name="entityPhoneContry" class="java.lang.String"/> 
<parameter name="invoiceDate" class="java.lang.String"/> 
<parameter name="invoiceDueDate" class="java.lang.String"/> 
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> 
    <defaultValueExpression><![CDATA["D:\\Ravi Workspace\\Openbrm\\open-brm-openbrm-2.0\\descriptors\\reports\\usage\\"]]></defaultValueExpression> 
</parameter> 
<queryString> 
    <![CDATA[select e.calling_number,e.duration,e.call_start_date,e.cost,e.destination_number,e.destination_descr,co.first_name,co.last_name,b.id as user_id from swiss_cdr_event e join order_process o join base_user b on b.id=e.user_id and e.order_id = o.order_id join contact co on e.user_id=co.user_id where o.invoice_id=$P{invoice_id} and b.entity_id=$P{entity_id} order by e.call_start_date asc;]]> 
</queryString> 
<field name="calling_number" class="java.lang.String"/> 
<field name="destination_number" class="java.lang.String"/> 
<field name="duration" class="java.lang.Integer"/> 
<field name="cost" class="java.math.BigDecimal"/> 
<field name="call_start_date" class="java.sql.Timestamp"/> 
<field name="destination_descr" class="java.lang.String"/> 
<field name="first_name" class="java.lang.String"/> 
<field name="last_name" class="java.lang.String"/> 
<field name="user_id" class="java.lang.Integer"/> 
<variable name="total" class="java.math.BigDecimal" calculation="Sum"> 
    <variableExpression><![CDATA[$F{cost}]]></variableExpression> 
</variable> 
<title> 
    <band height="111"/> 
</title> 
<columnHeader> 
    <band height="33"> 
     <staticText> 
      <reportElement x="12" y="10" width="62" height="15" /> 
      <textElement> 
       <font size="10" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Datum/Uhrzeit]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="240" y="10" width="85" height="15" /> 
      <textElement> 
       <font size="10" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Destination]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="450" y="10" width="42" height="15" /> 
      <textElement textAlignment="Left" verticalAlignment="Middle"> 
       <font size="10" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Menge]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="90" y="10" width="62" height="15" /> 
      <text><![CDATA[Anruf von]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="163" y="10" width="49" height="14" /> 
      <text><![CDATA[Service]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="334" y="10" width="100" height="15" /> 
      <text><![CDATA[Rufnummer]]></text> 
     </staticText> 
     <staticText> 
      <reportElement x="514" y="10" width="47" height="15" /> 
      <text><![CDATA[Betrag]]></text> 
     </staticText> 
    </band> 
</columnHeader> 
<detail> 
    <band height="20"> 
     <textField> 
      <reportElement x="360" y="3" width="193" height="16" /> 
      <textElement textAlignment="Right" verticalAlignment="Middle"> 
       <font size="9"/> 
      </textElement> 
      <textFieldExpression><![CDATA[new DecimalFormat("#,##0.00").format($F{cost})]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement x="12" y="3" width="96" height="16" /> 
      <textElement> 
       <font size="9"/> 
      </textElement> 
      <textFieldExpression><![CDATA[new SimpleDateFormat("dd-MM-yyyy").format($F{call_start_date})]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="242" y="3" width="121" height="16" /> 
      <textElement> 
       <font size="9"/> 
      </textElement> 
      <textFieldExpression><![CDATA[$F{destination_descr}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement x="60" y="3" width="96" height="16" /> 
      <textElement> 
       <font size="9"/> 
      </textElement> 
      <textFieldExpression><![CDATA[new SimpleDateFormat("HH:mm:ss").format($F{call_start_date})]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement x="450" y="4" width="100" height="16" /> 
      <textElement> 
       <font size="9"/> 
      </textElement> 
      <textFieldExpression class="java.lang.Integer"><![CDATA[$F{duration}]]></textFieldExpression> 
     </textField> 
     <subreport> 
      <reportElement x="302" y="0" width="129" height="20" /> 
      <subreportParameter name="invoiceId"> 
       <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression> 
      </subreportParameter> 
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
      <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "entity-details-31.jasper"]]></subreportExpression> 
     </subreport> 
     <textField> 
      <reportElement x="98" y="0" width="90" height="15" /> 
      <textFieldExpression><![CDATA[$P{entityCity}]]></textFieldExpression> 
     </textField> 
    </band> 
</detail> 
<summary> 
    <band height="80"> 
     <staticText> 
      <reportElement x="242" y="6" width="92" height="15" /> 
      <text><![CDATA[Total]]></text> 
     </staticText> 
     <textField> 
      <reportElement x="431" y="6" width="100" height="15" /> 
      <textElement textAlignment="Right"> 
       <font size="9" isBold="true"/> 
      </textElement> 
      <textFieldExpression><![CDATA[$V{total} == null ? "0.00" : new DecimalFormat ("#,##0.00").format($V{total})]]></textFieldExpression> 
     </textField> 
    </band> 
</summary> 

enter image description here

+0

'請解決我的問題' - 你是什麼意思? –

+0

我的意思是建議我如何解決這個問題 –

+1

和b.entity_id = $ P {} ENTITY_ID,你有沒有默認表情也不是你通過這個參數,以便您在b.entity_id =空濾,這是你是什麼試圖實現? –

回答

0

由於尋找到你的JR xml,您還必須將$ P {entity_id}傳遞給您的sub_report。目前,您僅傳遞發票編號$ P {invoice_id}。由於您的子報告sql正在處理兩個參數$ P {invoice_id}和$ P {entity_id}。如果你沒有通過,它會選擇默認值或null(如果沒有默認值)。

還有一個建議,子報告應該只包含那些需要的帶,並妥善安排你的文本字段,否則當你嘗試在excel下載時,你會得到excel列格式化問題。

當你點擊子報表並選擇屬性,那麼你會像第一個圖像。

enter image description here

現在點擊在性能報表標籤參數。請參閱第二張圖片。

enter image description here

有三個子報表在主JRXML。

1)運行在details.jrxml主JRXML 子報表參數映射 invoiceId:$ P {INVOICE_ID}

2)發票週期爲31.jrxml

子報表參數映射在主JRXML invoiceId:$ P {INVOICE_ID}

3)使用-31-DE-details.jrxml

子報表參數映射在主JRXML invoiceId:$ P {在voice_id}

我可以在3子報表中看到參數名稱是invoice_id。所以,你應該改變 子報表參數映射在主JRXML INVOICE_ID:$ P {} INVOICE_ID

,並3次報告正在ENTITY_ID參數。你也必須通過這個價值。 現在 子報表參數映射在主JRXML INVOICE_ID:$ P {} INVOICE_ID ENTITY_ID:$ P {} ENTITY_ID

我不知道什麼參數名稱已在另一個子報表中。

+0

我使用ENTITY_ID也subreport.If你看到查詢 –

+0

我說從主JRXML分報告 –

+0

我們需要在報表參數以ENTITY_ID在圖像 –

相關問題