columnFooter中的文字不会延伸

时间:2017-09-12 08:37:20

标签: jasper-reports

我在打印文本字段的内容时遇到问题。报告是一张发票,在列页脚中,我想根据发票数据打印一些可变文本。

我在Column Footer Band中定义了一个文本字段,它通过jasperstarter从参数发送中获取内容。

问题:
如果文本字段不适合文本字段,即使我设置了" Stretch with overflow",也会删除文本字段。如果我将文本字段放大,则会显示文本。

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="StandardInvoice002" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="53084288-6a86-4b4d-a942-fa8965b8d117">
    <queryString language="SQL">
        <![CDATA[$P!{query}]]>
    </queryString>
    <columnFooter>
        <band height="196" splitType="Stretch">
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="30" y="165" width="500" height="21" isRemoveLineWhenBlank="true" uuid="27681503-6210-41cc-b444-5b9c0d720f4b"/>
                <textElement markup="html"/>
                <textFieldExpression><![CDATA["this is a very long text (1)<br>this is a very long text (2)<br>this is a very long text (3)<br>this is a very long text (4)"]]></textFieldExpression>
            </textField>
        </band>
    </columnFooter>
</jasperReport>

enter image description here

  

Textfield包含4行,但只显示2行

1 个答案:

答案 0 :(得分:1)

columnFooter具有固定大小(与pageFooter一样),因此无法拉伸,因此您需要更改设计。

您正在寻找的是groupFooter显示在每个页面上并堆叠在底部。

示例

<?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="StandardInvoice002" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="53084288-6a86-4b4d-a942-fa8965b8d117">
    <queryString language="SQL">
        <![CDATA[]]>
    </queryString>
    <group name="pageGroup" footerPosition="StackAtBottom">
        <groupExpression><![CDATA[$V{PAGE_NUMBER}]]></groupExpression>
        <groupFooter>
            <band height="142">
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="121" width="555" height="21" isRemoveLineWhenBlank="true" uuid="27681503-6210-41cc-b444-5b9c0d720f4b"/>
                    <textElement markup="html"/>
                    <textFieldExpression><![CDATA["this is a very long text (1)<br>this is a very long text (2)<br>this is a very long text (3)<br>this is a very long text (4)"]]></textFieldExpression>
                </textField>
            </band>
        </groupFooter>
    </group>
</jasperReport>

<强>输出

output

只需调整groupExpression即可在您喜欢的页面上获得输出