How to avoid of missing cell's border when a r

2019-02-03 20:10发布

问题:

When the last entry in a page is too long, It will show in next page, when it show all the table line is missing.

This is the result:

How do I move the last record (no.26) to the next page, or how I can show the line?

回答1:

You can put the staticText element without text behind the textField element. You should set stretchType property with RelativeToTallestObject value and isPrintWhenDetailOverflows property with true value.

The sample:

<detail>
    <band height="20" splitType="Stretch">
        <staticText>
            <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
            <box>
                <leftPen lineWidth="1.0"/>
                <bottomPen lineWidth="1.0"/>
                <rightPen lineWidth="1.0"/>
            </box>
            <textElement/>
            <text><![CDATA[]]></text>
        </staticText>
        <textField>
            <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="20"/>
            <box>
                <leftPen lineWidth="1.0"/>
                <bottomPen lineWidth="1.0"/>
                <rightPen lineWidth="1.0"/>
            </box>
            <textElement/>
            <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
        </textField>

As result you will get the vertical border at the second page.

The result before adding the second staticText was (the vertical border at the second page is absent):



回答2:

Better way is to ensure, that new items in Detail band (or any band) will be generated on next page by setting, but not on the text field. For the band the text field is in, you can set the Split Type to Prevent. if you set that on the Detail Band and the row needs to overflow to next page, it will move the entire row to the next page.