如何仅显示具有多个页面的报表的y页面x [英] How to display the page x of y for only the reports which are having more than one page

查看:83
本文介绍了如何仅显示具有多个页面的报表的y页面x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jasper reports-4.5.0。我使用这个jasper以不同的格式生成报告。我想在报告中显示Y的页面X.所以我使用iReport提供的页码文本字段,它可以在调色板中找到。它在所有报告中显示页码,即使是具有单页的报告也是如此。

I am using the jasper reports-4.5.0. I am generating the reports in different formats using this jasper. I want to display the page X of Y in my reports. So I am using iReport provided page number text field which is available in palette. It is displaying the page number in all the reports even the reports which are having the single page also.

所以我的要求是,如果我的报告只有一页,我不想要y的页面x。我如何做到这一点?

So my requirement is I don't want the page x of y if my report has only one page. How do I accomplish this?

以下代码目前我根据给定的答案使用。

The below code is presently i am using according to the given answer.

<textField>
                    <reportElement x="395" y="121" width="20" height="20">
                       <printWhenExpression><![CDATA[$V{PAGE_COUNT} > 1]]></printWhenExpression>
                    </reportElement>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
                </textField>
                <textField evaluationTime="Report">
                    <reportElement x="350" y="121" width="45" height="20">
                    <printWhenExpression><![CDATA[$V{PAGE_COUNT} > 1]]></printWhenExpression>
                    </reportElement>
                    <textElement/>
                    <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>

如果我这样使用我的报告中的页码不会超过一页。

If i used like this i am not getting the page numbers in the reports which are having the more than one page.

推荐答案

您需要设置打印表达式时这两个字段包含Page+ $ V {PAGE_NUMBER} +of+ $ V {PAGE_NUMBER} 。具有这两个字段的jrxml部分应如下所示:

You need to set the Print When Expression for the two fields that contain "Page "+$V{PAGE_NUMBER}+" of" and " " + $V{PAGE_NUMBER}. The jrxml portion with this two fields should look something like:

<textField>
    <reportElement uuid="90a3462d-cfa2-4768-904a-1edf4191f1b7" x="250" y="16" width="80" height="20">
        <printWhenExpression><![CDATA[$V{PAGE_COUNT} > 1]]></printWhenExpression>
    </reportElement>
    <textElement textAlignment="Right"/>
    <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
    <reportElement uuid="01d43267-3247-48bb-9822-8b58ea860d7f" x="330" y="16" width="40" height="20">
        <printWhenExpression><![CDATA[$V{PAGE_COUNT} > 1]]></printWhenExpression>
    </reportElement>
    <textElement/>
    <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>

这篇关于如何仅显示具有多个页面的报表的y页面x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆