Jump to content
We've recently updated our Privacy Statement, available here ×

page x of y with subreport display null of y


vu.minh

Recommended Posts

Hi all,

actually im working with iReport 3.7.2 and try to display "page x of y", but page 1 of 16 is only displayed on the first page. All others show null of 16.

The structure of report is as followed:

title
detail band with subreport
page footer: page x of y
last page footer: page x of y

Im using the same mechanism for this scenario as described in official iReport manual.

Test sources are included.

Many thanks in advance

 

Main report

 

<?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="page_x_of_y" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">    <property name="ireport.zoom" value="1.9487171000000014"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <style name="Crosstab Data Text" hAlign="Center"/>    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">        <defaultValueExpression><![CDATA["C:\Users\vu\Documents\projekte\iReport\"]]></defaultValueExpression>    </parameter>    <queryString>        <![CDATA[/* just one row */select orderid from orderswhere orderid = 10248]]>    </queryString>    <field name="ORDERID" class="java.lang.Integer"/>    <variable name="act_pageno" class="java.lang.String" resetType="Page" incrementType="Page">        <variableExpression><![CDATA[$V{PAGE_NUMBER}]]></variableExpression>    </variable>    <title>        <band height="25" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="89" height="19"/>                <textElement>                    <font size="13" isBold="true"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["Test page X of Y with subreport"]]></textFieldExpression>            </textField>        </band>    </title>    <detail>        <band height="10">            <subreport>                <reportElement x="0" y="0" width="555" height="10"/>                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>                <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "page_x_of_y_subreport.jasper"]]></subreportExpression>            </subreport>        </band>    </detail>    <pageFooter>        <band height="20">            <textField>                <reportElement x="0" y="5" width="89" height="15"/>                <textElement>                    <font size="10" isBold="false"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["page " + $V{act_pageno} + " of " + $V{PAGE_NUMBER}]]></textFieldExpression>            </textField>        </band>    </pageFooter>    <lastPageFooter>        <band height="16">            <textField>                <reportElement x="0" y="0" width="89" height="15"/>                <textElement>                    <font size="10" isBold="false"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["last page " + $V{act_pageno} + " of " + $V{PAGE_NUMBER}]]></textFieldExpression>            </textField>        </band>    </lastPageFooter></jasperReport>[/code]

Subreport

<?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="page_x_of_y_subreport" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">    <property name="ireport.zoom" value="2.1435888100000016"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <queryString language="SQL">        <![CDATA[select orderid from orders]]>    </queryString>    <field name="ORDERID" class="java.lang.Integer"/>    <detail>        <band height="15" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="100" height="15"/>                <textElement/>                <textFieldExpression class="java.lang.String"><![CDATA["orderid = " + $F{ORDERID}]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]

 

Link to comment
Share on other sites

  • 4 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...