如何根据条件创建不同的页脚?

问题描述 投票:0回答:1

我要求根据条件显示不同的页脚。

我的页脚由许多静态标签组成,理论上我可以为每个标签定义“Print When Expression”。但这很不方便。

问:是否可以根据条件选择不同的页脚?

如果没有,我怎么能处理这种情况而不必在很多地方指定条件?

jasper-reports footer
1个回答
2
投票

xsd不允许或最多一个pageFooter标签,最大one乐队。

这是一个典型示例,您可以使用frame component对数据进行分组并决定是否显示它。

根据页码显示带有文本字段的不同帧的示例

<pageFooter>
    <band height="60" splitType="Stretch">
        <frame>
            <reportElement x="0" y="0" width="540" height="60" uuid="d0198e94-8325-4909-9804-a8d393600ec5">
                <printWhenExpression><![CDATA[$V{PAGE_NUMBER}%2!=0]]></printWhenExpression>
            </reportElement>
            <textField>
                <reportElement x="0" y="0" width="100" height="30" uuid="379e2ac0-63ea-4493-bd38-1b7ca7b35d8c"/>
                <textFieldExpression><![CDATA["Text Field 1"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="30" width="100" height="30" uuid="6598ba79-08b6-4997-953d-70b64f159e3b"/>
                <textFieldExpression><![CDATA["Text Field 2"]]></textFieldExpression>
            </textField>
        </frame>
        <frame>
            <reportElement x="0" y="0" width="540" height="60" uuid="d0198e94-8325-4909-9804-a8d393600ec5">
                <printWhenExpression><![CDATA[$V{PAGE_NUMBER}%2==0]]></printWhenExpression>
            </reportElement>
            <textField>
                <reportElement x="0" y="0" width="100" height="30" uuid="379e2ac0-63ea-4493-bd38-1b7ca7b35d8c"/>
                <textFieldExpression><![CDATA["Text Field 3"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="30" width="100" height="30" uuid="6598ba79-08b6-4997-953d-70b64f159e3b"/>
                <textFieldExpression><![CDATA["Text Field 4"]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</pageFooter>

将不同pageFooter的不同文本添加到不同的帧中,然后在帧组件上设置printWhenExpression。

© www.soinside.com 2019 - 2024. All rights reserved.