2

我正在使用iReport设计发票,但我遇到了格式问题。

我必须在信头上打印发票,那里有固定的位置来打印字段,例如总金额必须打印在固定在某个位置的盒子内。

这是信头的格式:

在此处输入图像描述

在底部有一个必须打印总金额的字段,但我无法这样做。

我使用iReport的输出:

iReport 的屏幕截图

在此处输入图像描述

在此处输入图像描述

这是我的 jrxml 文件:

<?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="LetterHeadInvoice" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <parameter name="COMPANY_ADDRESS" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="COMPANY_NAME" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="INVOICENO" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[SELECT DISTINCT c.docketno,c.bookingdate,c.rname,c.rcity,c.rcountry
       ,c.noofitems,c.actualweight,c.volweight,p.docketcharges,p.weight as weightused,
       p.total,i.type,c.sname,c.scity,c.scountry,c.bookingdate,s.fovtype ,s.fovamount,s.oditype ,s.odiamount,s.nformtype ,s.nformamount,o.fsetype,o.fseamount
 FROM  typedetails i,paymentdetails p,clientdetails c,subdetails s,otherdetails o
 WHERE i.id=c.typeid
 AND   c.docketno=p.docketno
And c.docketno= s.docketno
And c.docketno= o.docketno
  AND   c.docketno IN (SELECT docketnumber FROM invoice  WHERE InvoiceId=$P{INVOICENO})]]>
    </queryString>
    <field name="docketno" class="java.lang.String"/>
    <field name="bookingdate" class="java.sql.Timestamp"/>
    <field name="rname" class="java.lang.String"/>
    <field name="rcity" class="java.lang.String"/>
    <field name="rcountry" class="java.lang.String"/>
    <field name="noofitems" class="java.lang.Integer"/>
    <field name="actualweight" class="java.math.BigDecimal"/>
    <field name="volweight" class="java.lang.Short"/>
    <field name="docketcharges" class="java.lang.Integer"/>
    <field name="weightused" class="java.lang.Integer"/>
    <field name="total" class="java.lang.Integer"/>
    <field name="type" class="java.lang.String"/>
    <field name="sname" class="java.lang.String"/>
    <field name="scity" class="java.lang.String"/>
    <field name="scountry" class="java.lang.String"/>
    <field name="fovtype" class="java.lang.String"/>
    <field name="fovamount" class="java.lang.String"/>
    <field name="oditype" class="java.lang.String"/>
    <field name="odiamount" class="java.lang.String"/>
    <field name="nformtype" class="java.lang.String"/>
    <field name="nformamount" class="java.lang.String"/>
    <field name="fsetype" class="java.lang.String"/>
    <field name="fseamount" class="java.lang.Integer"/>
    <variable name="TOTAL" class="java.lang.Double" calculation="Sum">
        <variableExpression><![CDATA[$F{total}]]></variableExpression>
    </variable>
    <variable name="TOTAL2" class="java.lang.Double" incrementType="Column" calculation="Sum">
        <variableExpression><![CDATA[$V{TOTAL}+$F{fseamount}]]></variableExpression>
    </variable>
    <variable name="Tax" class="java.lang.Double">
        <variableExpression><![CDATA[$V{TOTAL2}/100.00*12.36]]></variableExpression>
    </variable>
    <background>
        <band height="802" splitType="Stretch">
            <image>
                <reportElement x="0" y="0" width="555" height="802"/>
                <imageExpression><![CDATA["C:\\Documents and Settings\\Hemant\\Desktop\\RNZImage.jpg"]]></imageExpression>
            </image>
        </band>
    </background>
    <title>
        <band height="205" splitType="Stretch">
            <staticText>
                <reportElement x="40" y="61" width="40" height="23"/>
                <textElement>
                    <font fontName="Lucida Bright" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Bill To]]></text>
            </staticText>
            <textField>
                <reportElement x="40" y="84" width="266" height="107"/>
                <textElement>
                    <font size="11"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{sname}+"\n"+$F{scity}+","+$F{scountry}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="324" y="95" width="91" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$P{INVOICENO}]]></textFieldExpression>
            </textField>
            <textField pattern="dd/MM/yyyy">
                <reportElement x="429" y="96" width="104" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <textField pattern="MMMMM-yy">
                <reportElement x="312" y="145" width="83" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <detail>
        <band height="112" splitType="Stretch">
            <textField pattern="MM/dd/yyyy">
                <reportElement x="28" y="31" width="52" height="20"/>
                <textElement>
                    <font size="9"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{bookingdate}.toString().substring(0,$F{bookingdate}.toString().indexOf(" "))]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="82" y="31" width="54" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{docketno}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="164" y="31" width="77" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{rcity}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="261" y="31" width="35" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{rcity}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="306" y="31" width="33" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{noofitems}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="345" y="31" width="33" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{weightused}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="395" y="31" width="73" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{type}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="480" y="31" width="48" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{docketcharges}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="346" y="90" width="123" height="17" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{oditype}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="480" y="90" width="55" height="17" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{odiamount}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="346" y="56" width="123" height="17" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{fovtype}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="480" y="73" width="55" height="17" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{nformamount}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="346" y="73" width="123" height="17" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{nformtype}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="480" y="56" width="55" height="17" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{fovamount}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="280" splitType="Stretch">
            <textField>
                <reportElement x="478" y="12" width="59" height="20"/>
                <textElement markup="none"/>
                <textFieldExpression><![CDATA[$V{TOTAL}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="334" y="32" width="128" height="17">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{fsetype}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="478" y="32" width="59" height="17">
                    <printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA[$F{fseamount}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="334" y="49" width="128" height="20"/>
                <textElement/>
                <text><![CDATA[TOTAL]]></text>
            </staticText>
            <staticText>
                <reportElement x="334" y="12" width="128" height="20"/>
                <textElement/>
                <text><![CDATA[SUB TOTAL]]></text>
            </staticText>
            <textField pattern="###0.00">
                <reportElement x="478" y="69" width="59" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{TOTAL2}/100.00*12.36]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="478" y="49" width="59" height="20"/>
                <textElement markup="none"/>
                <textFieldExpression><![CDATA[$V{TOTAL}+$F{fseamount}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="334" y="69" width="128" height="20"/>
                <textElement/>
                <text><![CDATA[Service Tax At 12.36%]]></text>
            </staticText>
            <textField pattern="###0.00">
                <reportElement x="464" y="252" width="73" height="20"/>
                <textElement>
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{TOTAL2}+$V{Tax}]]></textFieldExpression>
            </textField>
        </band>
    </summary>
</jasperReport>
4

1 回答 1

1

您应该尝试将此文本字段(带有表达式)的位置类型更改为固定相对于底部浮动。$V{TOTAL2}+$V{Tax}

<textField pattern="###0.00">
    <reportElement positionType="FixRelativeToBottom" x="464" y="252" width="73" height="20"/>
    <textElement>
        <font size="11" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$V{TOTAL2}+$V{Tax}]]></textFieldExpression>
</textField>
于 2012-09-01T16:21:20.397 回答