How to add empty max row in Jasper report?

时间:2019-04-08 13:24:35

标签: jasper-reports

I want to add empty records after the end of rows. I am trying to fixing rows per page. Without data I need blank lines in my jasper report. Is it possible?

This is my source code:

<detail>
    <band height="24">
        <line>
            <reportElement x="1" y="22" width="801" height="1" uuid="dc8cb0ba-10e2-4fe4-be84-9b6f71e94fea"/>
        </line>
        <line>
            <reportElement x="0" y="-1" width="1" height="24" uuid="1946ddf4-1087-43a7-91c7-774237d8cb19"/>
        </line>
        <line>
            <reportElement x="60" y="-1" width="1" height="24" uuid="ac4afafc-2517-4355-9e42-065079e6349f"/>
        </line>
        <line>
            <reportElement x="120" y="-1" width="1" height="24" uuid="51901938-647b-48ab-a23c-9f46cc7af0a1"/>
        </line>
        <line>
            <reportElement x="361" y="-2" width="1" height="24" uuid="0cefe047-9c23-4bf3-8596-b96000f24a87"/>
        </line>
        <line>
            <reportElement x="495" y="-1" width="1" height="24" uuid="92b2c4c7-0871-4b55-be28-b45598906c9b"/>
        </line>
        <line>
            <reportElement x="187" y="-1" width="1" height="23" uuid="a76d5a9d-08a7-42f8-9931-2afc1f085e62"/>
        </line>

1 个答案:

答案 0 :(得分:2)

尝试一下,

使用背景带在行尾添加空白记录

<background>
        <band height="307" splitType="Stretch">
            <line>
                <reportElement x="0" y="145" width="555" height="1" uuid="8184649e-10af-49b8-9f36-9df1020a2371"/>
            </line>
            <!-- add the suitable amount of lines -->
</background>

此解决方案的示例(jrxml文件)

<jasperReport xmlns=".....">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band height="328" splitType="Stretch">
            <line>
                <reportElement x="0" y="169" width="555" height="1" uuid="8184649e-10af-49b8-9f36-9df1020a2371"/>
            </line>
            <line>
                <reportElement x="0" y="199" width="555" height="1" uuid="86060b38-40cc-4963-be7d-21df01a8aaa1"/>
            </line>
            <line>
                <reportElement x="0" y="229" width="555" height="1" uuid="a531a915-b5cf-4854-9eb6-2981768b4db3"/>
            </line>
            <line>
                <reportElement x="0" y="259" width="555" height="1" uuid="edb3bab2-0562-4e82-bbd0-763508148054"/>
            </line>
            <line>
                <reportElement x="0" y="289" width="555" height="1" uuid="e0826eaa-7846-495f-9096-b07733283f9b"/>
            </line>
            <line>
                <reportElement x="0" y="319" width="555" height="1" uuid="6b199ad4-87aa-4d47-9751-46a3e277b919"/>
            </line>
        </band>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="555" height="30" uuid="496a564f-23a2-41eb-9e55-8faf2ba6b7dd"/>
                <textElement textAlignment="Center">
                    <font size="20"/>
                </textElement>
                <text><![CDATA[Title]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="555" height="30" uuid="f3677b34-d2e8-45db-923f-76dc120624b6"/>
                <textElement textAlignment="Center">
                    <font size="20"/>
                </textElement>
                <text><![CDATA[Page Header]]></text>
            </staticText>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="31" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="555" height="30" uuid="439da16b-0dc3-4e1e-a367-dcf66405a5d3"/>
                <textElement textAlignment="Center">
                    <font size="20"/>
                </textElement>
                <text><![CDATA[Table Header]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="24" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="555" height="24" uuid="96bc78b4-7796-4b6b-9ed8-d13abd506522"/>
                <textElement textAlignment="Center">
                    <font size="18"/>
                </textElement>
                <textFieldExpression><![CDATA["Data in detail band"]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

上述jrxml文件的预览

enter image description here