Jasper报告文本字段创建两行

时间:2018-09-21 08:37:24

标签: jasper-reports

我做了一个碧玉报告,打印成PDF,但是很明显,其中一个字段创建了两行。每次我在iReport 4.0.2中测试该报告时,该字段看起来都不错,但是每当将其打印为PDF格式时,它就会失真。请参考下图:

来自iReport: enter image description here

从PDF打印: enter image description here

有人知道我可能会缺少什么吗? XML如下:

<?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="LTOManila_REPORT_FILE" pageWidth="698" pageHeight="828" columnWidth="698" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
    <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
    <property name="ireport.zoom" value="1.331000000000001"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["./"]]></defaultValueExpression>
    </parameter>
    <parameter name="TRX_DATE" class="java.lang.String">
        <defaultValueExpression><![CDATA[$P{TRX_DATE}]]></defaultValueExpression>
    </parameter>
    <parameter name="BILLER_ID" class="java.lang.Integer">
        <defaultValueExpression><![CDATA[$P{BILLER_ID}]]></defaultValueExpression>
    </parameter>
    <parameter name="PROCESSED_STATUS" class="java.lang.String">
        <defaultValueExpression><![CDATA[$P{PROCESSED_STATUS}]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[Declare @billId INT=$P{BILLER_ID};
Declare @trxDate VARCHAR(10)=$P{TRX_DATE};
--Declare @billId INT=424;
--Declare @trxDate VARCHAR(10)='2018-05-16';

SELECT
    ROW_NUMBER() OVER(ORDER BY x.UNIVERSAL_TRX_ID) ROWS_RECORD,
    x.SOA_REFERENCE_NUM,
    x.UNIVERSAL_TRX_ID,
    x.BILLER_NAME,
    x.BRANCH_CODE,
    x.BRANCH_NAME,
    SUM(x.CASH_AMOUNT) CASH_AMOUNT,
    SUM(x.CHECK_AMOUNT) CHECK_AMOUNT,
    x.TRX_HDR_ID,
    x.TRX_DATE,
    MAX(x.CHECK_NUMBER) CHECK_NUMBER,
    x.CUSTOMER_NAME,
    SUM(CAST(x.CASH_AMOUNT as Money)+CAST(x.CHECK_AMOUNT as Money)) TOTAL_AMOUNT
FROM
(
    SELECT DISTINCT
        LINE.UNIVERSAL_TRX_ID,
        UPPER(BILL.BILLER_NAME) BILLER_NAME,
        RIGHT(BR.BRANCH_CODE, 4) BRANCH_CODE,
        BR.BRANCH_NAME,
        LINE.SOA_REFERENCE_NUM,
        CASE PAY.TENDER_ID WHEN 1 THEN PAY.TENDER_AMOUNT - (ISNULL(F_PASS.SERVICE_FEE_AMOUNT,0.00)+ISNULL(F_DED.SERVICE_FEE_AMOUNT,0.00)) ELSE 0.00 END CASH_AMOUNT,
        CASE PAY.TENDER_ID WHEN 2 THEN PAY.TENDER_AMOUNT ELSE 0.00 END CHECK_AMOUNT,
        CASE PAY.TENDER_ID WHEN 2 THEN PAY.TENDER_REF_NUM ELSE 0 END CHECK_NUMBER,
        CAST(REVERSE(SUBSTRING(REVERSE(HEAD.UNIVERSAL_TRX_ID), 0,10)) AS INTEGER) TRX_HDR_ID,
        CONVERT(VARCHAR(10), LINE.CREATION_DATE, 101) TRX_DATE,
        UPPER(CONVERT(varchar(40),ISNULL(dbo.FN_GETFIELD_VALUE(LINE.TRX_LINE_ID,'accName'),' '))) CUSTOMER_NAME,
        PAY.TENDER_AMOUNT,
        PAY.TENDER_REF_NUM
    FROM BPS_TRX_LINES LINE
    LEFT JOIN BPS_TRX_HEADER HEAD WITH(NOLOCK) ON LINE.TRX_HDR_ID = HEAD.TRX_HDR_ID
    LEFT JOIN BPS_BILLER BILL WITH(NOLOCK) ON LINE.BILLER_ID = BILL.BILLER_ID
    LEFT JOIN BPS_BRANCH BR WITH(NOLOCK) ON HEAD.BRANCH_ID = BR.BRANCH_ID
    LEFT JOIN BPS_TRX_LINE_PAYMENTS PAY WITH(NOLOCK) ON LINE.TRX_LINE_ID = PAY.TRX_LINE_ID
        AND LINE.TRX_LINE_NUM = PAY.TRX_LINE_NUM
    LEFT JOIN BPS_TRX_LINE_SERVICE_FEE F_PASS WITH(NOLOCK) ON LINE.TRX_LINE_ID = F_PASS.TRX_LINE_ID
        AND F_PASS.SERVICE_FEE_ID = 2
    LEFT JOIN BPS_TRX_LINE_SERVICE_FEE F_DED WITH(NOLOCK) ON LINE.TRX_LINE_ID = F_DED.TRX_LINE_ID
        AND F_DED.SERVICE_FEE_ID = 3
    WHERE
    LINE.BILLER_ID = @billId
    AND CAST(HEAD.TRX_DATE AS DATE) = CAST(@trxDate AS DATE)
    AND HEAD.TRX_STATUS IN ('SAVE','CASHIER VOID','MANAGER VOID APPROVED')
    --AND LINE.LINE_PROCESSED_STATUS IN ($P!{PROCESSED_STATUS})
    AND LINE.LINE_PROCESSED_STATUS IN ('P','N','o')
)x

GROUP BY x.UNIVERSAL_TRX_ID,
         x.BILLER_NAME,
         x.BRANCH_CODE,
         x.BRANCH_NAME,
         x.TRX_HDR_ID,
         x.TRX_DATE,
         x.CUSTOMER_NAME,
         x.SOA_REFERENCE_NUM]]>
    </queryString>
    <field name="BILLER_NAME" class="java.lang.String"/>
    <field name="BRANCH_CODE" class="java.lang.String"/>
    <field name="BRANCH_NAME" class="java.lang.String"/>
    <field name="SOA_REFERENCE_NUM" class="java.lang.String"/>
    <field name="CASH_AMOUNT" class="java.math.BigDecimal"/>
    <field name="CHECK_AMOUNT" class="java.math.BigDecimal"/>
    <field name="TOTAL_AMOUNT" class="java.math.BigDecimal"/>
    <field name="CHECK_NUMBER" class="java.lang.String"/>
    <field name="TRX_HDR_ID" class="java.lang.Integer"/>
    <field name="TRX_DATE" class="java.lang.String"/>
    <field name="CUSTOMER_NAME" class="java.lang.String"/>
    <variable name="CASH_AMT_SUB_SUM" class="java.math.BigDecimal" resetType="Group" resetGroup="BRANCH_NAME" calculation="Sum">
        <variableExpression><![CDATA[$F{CASH_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[new BigDecimal(0)]]></initialValueExpression>
    </variable>
    <variable name="CHECK_AMT_SUB_SUM" class="java.math.BigDecimal" resetType="Group" resetGroup="BRANCH_NAME" calculation="Sum">
        <variableExpression><![CDATA[$F{CHECK_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[new BigDecimal(0)]]></initialValueExpression>
    </variable>
    <variable name="TOTAL_AMT_SUB_SUM" class="java.math.BigDecimal" resetType="Group" resetGroup="BRANCH_NAME" calculation="Sum">
        <variableExpression><![CDATA[$F{TOTAL_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[new BigDecimal(0)]]></initialValueExpression>
    </variable>
    <variable name="CASH_AMT_GRAND_SUM" class="java.math.BigDecimal" calculation="Sum">
        <variableExpression><![CDATA[$F{CASH_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[new BigDecimal(0)]]></initialValueExpression>
    </variable>
    <variable name="CHECK_AMT_GRAND_SUM" class="java.math.BigDecimal" calculation="Sum">
        <variableExpression><![CDATA[$F{CHECK_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[new BigDecimal(0)]]></initialValueExpression>
    </variable>
    <variable name="BREC-COUNT" class="java.lang.Integer" resetType="Group" resetGroup="BRANCH_NAME" calculation="Count">
        <variableExpression><![CDATA[$F{CASH_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[]]></initialValueExpression>
    </variable>
    <variable name="TOTAL_AMT_GRAND_SUM" class="java.math.BigDecimal" calculation="Sum">
        <variableExpression><![CDATA[$F{TOTAL_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[new BigDecimal(0)]]></initialValueExpression>
    </variable>
    <variable name="TREC-COUNT" class="java.lang.Integer" calculation="Count">
        <variableExpression><![CDATA[$F{CASH_AMOUNT}]]></variableExpression>
        <initialValueExpression><![CDATA[]]></initialValueExpression>
    </variable>
    <variable name="test" class="java.lang.String">
        <variableExpression><![CDATA[]]></variableExpression>
    </variable>
    <group name="BRANCH_NAME">
        <groupExpression><![CDATA[$F{BRANCH_NAME}]]></groupExpression>
        <groupHeader>
            <band height="30" splitType="Prevent">
                <staticText>
                    <reportElement x="55" y="15" width="110" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[ACCOUNT NUMBER ]]></text>
                </staticText>
                <staticText>
                    <reportElement x="165" y="15" width="110" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[ACCOUNT NAME   ]]></text>
                </staticText>
                <staticText>
                    <reportElement x="275" y="15" width="90" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[CASH  ]]></text>
                </staticText>
                <staticText>
                    <reportElement x="55" y="0" width="110" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[BRANCH CODE:   ]]></text>
                </staticText>
                <textField>
                    <reportElement x="165" y="0" width="110" height="15" isPrintInFirstWholeBand="true"/>
                    <textElement verticalAlignment="Middle" markup="none">
                        <font fontName="SansSerif" size="8" isBold="false"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{BRANCH_CODE}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="365" y="15" width="90" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[CHECK   ]]></text>
                </staticText>
                <staticText>
                    <reportElement x="455" y="15" width="90" height="15"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[TOTAL AMOUNT   ]]></text>
                </staticText>
                <staticText>
                    <reportElement x="545" y="15" width="80" height="15"/>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[CHECK NUMBER   ]]></text>
                </staticText>
            </band>
        </groupHeader>
        <groupFooter>
            <band height="60">
                <textField>
                    <reportElement x="55" y="15" width="136" height="15" isPrintInFirstWholeBand="true"/>
                    <textElement verticalAlignment="Middle">
                        <font fontName="SansSerif"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{BRANCH_NAME}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="191" y="15" width="84" height="15" isPrintInFirstWholeBand="true"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle" markup="none">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[SUBTOTAL:   ]]></text>
                </staticText>
                <textField pattern="#,##0.00">
                    <reportElement x="275" y="15" width="90" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineWidth="0.0" lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font fontName="SansSerif"/>
                    </textElement>
                    <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{CASH_AMT_SUB_SUM}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="191" y="30" width="84" height="15" isPrintInFirstWholeBand="true"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle" markup="none">
                        <font fontName="SansSerif" size="8" isBold="true"/>
                    </textElement>
                    <text><![CDATA[COUNT:   ]]></text>
                </staticText>
                <textField pattern="#,##0">
                    <reportElement x="275" y="30" width="90" height="15" isPrintInFirstWholeBand="true"/>
                    <box>
                        <pen lineStyle="Dashed"/>
                        <topPen lineWidth="0.0" lineStyle="Dashed"/>
                        <leftPen lineStyle="Dashed"/>
                        <bottomPen lineWidth="0.0" lineStyle="Dashed"/>
                        <rightPen lineStyle="Dashed"/>
                    </box>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font fontName="SansSerif"/>
                    </textElement>
                    <textFieldExpression class="java.lang.Integer"><![CDATA[$V{BREC-COUNT}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="365" y="15" width="90" height="15"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle"/>
                    <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{CHECK_AMT_SUB_SUM}]]></textFieldExpression>
                </textField>
                <textField pattern="#,##0.00;(-#,##0.00)">
                    <reportElement x="455" y="15" width="90" height="15"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle"/>
                    <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{TOTAL_AMT_SUB_SUM}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="275" y="0" width="90" height="15"/>
                    <textElement textAlignment="Right"/>
                    <text><![CDATA[ - - - - - - - - - - - - - - - - -]]></text>
                </staticText>
                <staticText>
                    <reportElement x="365" y="0" width="90" height="15"/>
                    <textElement textAlignment="Right"/>
                    <text><![CDATA[ - - - - - - - - - - - - - - - - -]]></text>
                </staticText>
                <staticText>
                    <reportElement x="455" y="0" width="90" height="15"/>
                    <textElement textAlignment="Right"/>
                    <text><![CDATA[ - - - - - - - - - - - - - - - - -]]></text>
                </staticText>
            </band>
        </groupFooter>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band height="60">
            <textField>
                <reportElement x="55" y="15" width="477" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
                    <font fontName="SansSerif"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["BILLS PAYMENT SYSTEM  "+$F{BILLER_NAME}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="55" y="30" width="477" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
                    <font fontName="SansSerif"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["COLLECTION REPORT  " +  $F{TRX_DATE} +" "]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="45" width="680" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="SansSerif"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[]]></text>
            </staticText>
            <staticText>
                <reportElement x="55" y="0" width="477" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="SansSerif"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[SHOEMART, INC.   ]]></text>
            </staticText>
            <staticText>
                <reportElement x="532" y="0" width="65" height="15"/>
                <textElement>
                    <font fontName="SansSerif"/>
                </textElement>
                <text><![CDATA[PAGE NO.:   ]]></text>
            </staticText>
            <staticText>
                <reportElement x="532" y="15" width="65" height="15"/>
                <textElement>
                    <font fontName="SansSerif"/>
                </textElement>
                <text><![CDATA[RUNDATE:   ]]></text>
            </staticText>
            <staticText>
                <reportElement x="532" y="30" width="65" height="15"/>
                <textElement>
                    <font fontName="SansSerif"/>
                </textElement>
                <text><![CDATA[RUNTIME:   ]]></text>
            </staticText>
            <textField>
                <reportElement x="596" y="0" width="100" height="15"/>
                <textElement>
                    <font fontName="SansSerif"/>
                </textElement>
                <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="596" y="15" width="100" height="15"/>
                <textElement>
                    <font fontName="SansSerif"/>
                </textElement>
                <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="596" y="30" width="100" height="15"/>
                <textElement>
                    <font fontName="SansSerif"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[new SimpleDateFormat("hh:mm:ss").format((new java.util.Date()))]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <detail>
        <band height="15" splitType="Prevent">
            <textField>
                <reportElement x="55" y="0" width="110" height="15"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="SansSerif" size="10"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{SOA_REFERENCE_NUM}]]></textFieldExpression>
            </textField>
            <textField pattern="#,##0.00">
                <reportElement x="275" y="0" width="90" height="15" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font fontName="SansSerif" size="10"/>
                </textElement>
                <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{CASH_AMOUNT}]]></textFieldExpression>
            </textField>
            <textField pattern="#,##0.00">
                <reportElement x="365" y="0" width="90" height="15" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Right">
                    <font fontName="SansSerif" size="10"/>
                </textElement>
                <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{CHECK_AMOUNT}]]></textFieldExpression>
            </textField>
            <textField pattern="#,##0.00">
                <reportElement x="455" y="0" width="90" height="15"/>
                <textElement textAlignment="Right">
                    <font fontName="SansSerif" size="10"/>
                </textElement>
                <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{TOTAL_AMOUNT}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="545" y="0" width="80" height="15"/>
                <textElement textAlignment="Center">
                    <font fontName="SansSerif" size="10"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{CHECK_NUMBER}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="165" y="0" width="110" height="15"/>
                <textElement markup="html">
                    <font size="10"/>
                    <paragraph tabStopWidth="100"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{CUSTOMER_NAME} + ""]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="83"/>
    </summary>
</jasperReport>

0 个答案:

没有答案