我已經添加了主報表的子報表,通過從發票數據庫表中獲取詳細信息來打印發票編號,duedate和total的值。 但我無法使用參數打印字段。 請任何人都可以幫助我。我是jasper報告設計的新手。如何使用ireports添加子報表?
我的代碼:
<?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="Subscription_details" pageWidth="595" pageHeight="70" 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"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="customerId" class="java.lang.String"/>
<parameter name="invoiceId" class="java.lang.Integer"/>
<parameter name="totalWithTax" class="java.lang.String"/>
<parameter name="carriedBalance" class="java.lang.String"/>
<queryString>
<![CDATA[select i.amount as amount,i.due_date as duedate,i.id as invoiceId from invoice i where i.id=$P{invoiceId};]]>
</queryString>
<field name="description" class="java.lang.String"/>
<field name="price_per_item" class="java.math.BigDecimal"/>
<field name="quantity" class="java.lang.Integer"/>
<field name="amount" class="java.math.BigDecimal"/>
<columnHeader>
<band height="34">
<staticText>
<reportElement x="12" y="10" width="100" height="16" />
<textElement>
<font size="11" isBold="false"/>
</textElement>
<text><![CDATA[Racun od]]></text>
</staticText>
<staticText>
<reportElement x="180" y="10" width="70" height="14" />
<textElement>
<font size="10" isBold="false"/>
</textElement>
<text><![CDATA[Nacl Pl.]]></text>
</staticText>
<staticText>
<reportElement x="374" y="10" width="70" height="14" />
<textElement>
<font size="10" isBold="false"/>
</textElement>
<text><![CDATA[Iznos]]></text>
</staticText>
<line>
<reportElement x="12" y="33" width="543" height="1" />
<graphicElement>
<pen lineWidth="0.5"/>
</graphicElement>
</line>
<staticText>
<reportElement x="263" y="12" width="100" height="14" />
<textElement>
<font size="10"/>
</textElement>
<text><![CDATA[Broj Racuna]]></text>
</staticText>
<staticText>
<reportElement x="484" y="12" width="71" height="14" />
<textElement>
<font size="10"/>
</textElement>
<text><![CDATA[Otvoreno]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="17">
<textField>
<reportElement x="154" y="0" width="100" height="11" >
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{duedate}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="20">
<staticText>
<reportElement x="261" y="1" width="113" height="15" forecolor="#000000" />
<textElement textAlignment="Left" verticalAlignment="Bottom">
<font size="10" isBold="false"/>
</textElement>
<text><![CDATA[Ukupno CHF . . . .
]]></text>
</staticText>
<textField>
<reportElement x="344" y="0" width="100" height="13" >
<printWhenExpression><![CDATA[new Boolean($F{amount}!==null)]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{amount}]]></textFieldExpression>
</textField>
<line>
<reportElement x="12" y="1" width="543" height="1" />
<graphicElement>
<pen lineWidth="0.5"/>
</graphicElement>
</line>
<line>
<reportElement x="254" y="17" width="301" height="1" />
<graphicElement>
<pen lineWidth="0.5"/>
</graphicElement>
</line>
</band>
</summary>
</jasperReport>