如何在jasper报告中显示页码

时间:2017-01-06 13:43:18

标签: jasper-reports subreport

我们如何在jasper子报告中显示当前页码?我已经完成了第一页的变量,如$V{PAGE_NUMBER} and "("+$V{PAGE_COUNT}+")",但我们如何在所有子报告中显示?

2 个答案:

答案 0 :(得分:1)

按照以下模式,它应该有效。

<jasperReport>
<title>
</title>
<detail>
//Here goes all subreports
</detail>
<pageFooter>
<textField evaluationTime="Report">
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</pageFooter>
</jasperReport>

答案 1 :(得分:1)

你必须使用页脚页带,

当表达式为&#34; REPORT&#34; 时,

设置$V{PAGE_NUMBER}的打印件,当您必须显示总页数时,

当您必须显示当前页码时,

$V{PAGE_NUMBER}在表达&#34; NOW&#34; 时打印。

尝试

    <pageFooter>
    <band height="22" splitType="Stretch">

        <textField pattern="M/d/yy h:mm a">
            <reportElement x="580" y="0" width="220" height="20" uuid="941d5c67-e986-4d5b-ba7e-2754f065e008"/>
            <box padding="3"/>
            <textElement textAlignment="Right" verticalAlignment="Middle">
                <font fontName="SansSerif" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA["Printed on : "+new java.util.Date()]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="280" y="1" width="200" height="20" uuid="afe76ecf-00e9-4d52-a00b-44d38dc3aa65"/>
            <box padding="3"/>
            <textElement textAlignment="Center" verticalAlignment="Middle">
                <font fontName="SansSerif" size="8" isBold="true"/>
            </textElement>
            <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>