细节部分在字段之间留下空格。我怎样才能消除这种情况?

时间:2011-03-16 14:17:03

标签: java reporting jasper-reports report

我正在使用最新版本的Jasper Reports。我在Jasper Report的详细部分中使用了两个帧。一个帧包含其中所有需要的字段,并设置在顶部= 0,第二帧正好在第一帧之下,只包含一个字段。当第一帧的文本字段中的文本正常(适合宽度并且不拉伸)时,结果是正常的,意味着第二帧正好打印在第一帧之下。但是如果其中一个文本字段被拉伸,如果内容超过流,那么它会在两个帧之间留下一些空间。

我在这里写了我的详细信息部分的XML。

<detail>
        <band height="40" splitType="Stretch">
            <frame>
                <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="430" height="20" isPrintWhenDetailOverflows="true"/>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="129" y="0" width="50" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{netWeight}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="179" y="0" width="50" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{metalRate}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="54" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{productName}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="229" y="0" width="22" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{ratePer}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="251" y="0" width="25" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{ratePerUnit}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="364" y="0" width="66" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{totalAmount}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="104" y="0" width="25" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{piece}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="54" y="0" width="50" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{itemName}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="320" y="0" width="44" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{vatAmount}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement stretchType="RelativeToTallestObject" x="276" y="0" width="44" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{labourAmount}]]></textFieldExpression>
                </textField>
            </frame>
            <frame>
                <reportElement x="0" y="20" width="430" height="20" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true">
                    <printWhenExpression><![CDATA[$F{narration} != null && (!$F{narration}.equals("NONE")) && $F{narration}.length > 0]]></printWhenExpression>
                </reportElement>
                <staticText>
                    <reportElement x="0" y="0" width="50" height="20"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <text><![CDATA[Narration]]></text>
                </staticText>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="50" y="0" width="380" height="20" isPrintWhenDetailOverflows="true"/>
                    <box leftPadding="1">
                        <pen lineWidth="1.0"/>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{narration}]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </detail>

1 个答案:

答案 0 :(得分:0)

我有解决方案,所以我在这里发帖,所以如果遇到同样的问题,任何人都会使用它。

  

尝试将帧设置为   positionType = “浮动”。