3

是否有可能获得条件,只有当元素的详细信息带是 Jasper Reports 中的最后一页时,我才能打印元素?

我们可以在页面上有变量说记录号。但是我们如何得到每一页的计算总记录呢?

4

1 回答 1

1

这是通过变量上的“重置类型”完成的

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="612" pageHeight="792" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="10" bottomMargin="10" uuid="39852bd8-6125-4359-8d76-06927e7be492">
    <queryString>
        <![CDATA[SELECT ROWNUM N FROM dual  CONNECT BY LEVEL <= 200 ]]>
    </queryString>
    <field name="N" class="java.math.BigDecimal"/>
    <variable name="N_count_page" class="java.lang.Integer" resetType="Page" calculation="Count">
        <variableExpression><![CDATA[$F{N}]]></variableExpression>
    </variable>
    <variable name="N_count_report" class="java.lang.Integer" calculation="Count">
        <variableExpression><![CDATA[$F{N}]]></variableExpression>
    </variable>
    <title>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement uuid="93284d9f-1ee0-4a15-b227-31b55aa2e48b" x="0" y="0" width="376" height="20"/>
                <textElement textAlignment="Center">
                    <font size="14" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Page Count"]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="20">
            <staticText>
                <reportElement uuid="a7113fdd-591b-4fee-9123-981ab75c6fa6" mode="Opaque" x="0" y="0" width="100" height="20" forecolor="#FFFFFF" backcolor="#000000"/>
                <textElement/>
                <text><![CDATA[N]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="20">
            <textField>
                <reportElement uuid="54bac746-4efb-4412-81bc-b4ba807c60fd" x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{N}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <pageFooter>
        <band height="50">
            <staticText>
                <reportElement uuid="4c685263-0ef7-4a68-a328-39901ef2806f" x="0" y="0" width="100" height="20"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Rows on page :]]></text>
            </staticText>
            <textField>
                <reportElement uuid="c65214f1-82dc-476a-8439-087854bbc5c6" x="100" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{N_count_page}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="48b37aff-b169-4ca2-b9dd-30c026988f68" x="289" y="30" width="80" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement uuid="983ccfed-d783-429e-bc6c-3fa488b2e106" x="369" y="30" width="40" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
    <lastPageFooter>
        <band height="64">
            <staticText>
                <reportElement uuid="240e2f86-991a-4fc1-941b-56cc43b28c25" x="0" y="24" width="100" height="20"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Rows on report :]]></text>
            </staticText>
            <textField>
                <reportElement uuid="718d4481-4716-4071-9989-27d5119fb428" x="100" y="24" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{N_count_report}]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement uuid="f03359be-3bbe-4da8-9bd8-ac024aa6f289" x="369" y="44" width="40" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="ad4aa2c0-9ad8-4892-a16f-0bb584c93916" x="289" y="44" width="80" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement uuid="b4bdd29a-4ef9-46cc-a57a-df7577bdd73f" x="0" y="0" width="100" height="20"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Rows on page :]]></text>
            </staticText>
            <textField>
                <reportElement uuid="39952747-170c-4747-8e2c-0e12ab608ae9" x="100" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{N_count_page}]]></textFieldExpression>
            </textField>
        </band>
    </lastPageFooter>
</jasperReport>
于 2012-10-25T14:50:43.520 回答