Search code examples
jasper-reports

In jasper Soft Studio ,I have 2 page footers. For footer1. I want the position should be normal, and for footer 2. I want position force to bottom


In jasper Soft Studio ,I have 2 page footers. For footer one, I want the position should be normal and for footer 2, I want position force to bottom. How can I do that?

If I am setting the position to force to bottom by default the position for both changes to force to bottom but I want one at bottom and second at normal.


Solution

  • I don't think you are using page footers. I'm assuming you have two footer bands for one group. As both of these footer bands belong to the same group they share the same properties. I'd say maybe use one group footer band (set to normal) and the page footer (which is at the bottom by default) or a second group with a same expression which will give you two independent group footers.

    Here is an example that groups on $F{Country} with two (independent) groups.

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.1.1  -->
    <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="Blank_A4_" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="62ac07f5-f11e-4179-aedb-a42e850c1ea8">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="northwind"/>
        <queryString language="jsonql">
            <![CDATA[Northwind.Customers]]>
        </queryString>
        <field name="City" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="City"/>
            <fieldDescription><![CDATA[City]]></fieldDescription>
        </field>
        <field name="Country" class="java.lang.String">
            <property name="net.sf.jasperreports.json.field.expression" value="Country"/>
            <fieldDescription><![CDATA[Country]]></fieldDescription>
        </field>
        <field name="ContactName" class="java.lang.String">
            <property name="net.sf.jasperreports.json.field.expression" value="ContactName"/>
            <fieldDescription><![CDATA[ContactName]]></fieldDescription>
        </field>
        <sortField name="Country"/>
        <group name="City" footerPosition="ForceAtBottom">
            <groupExpression><![CDATA[$F{Country}]]></groupExpression>
        </group>
        <group name="Group1">
            <groupExpression><![CDATA[$F{City}]]></groupExpression>
        </group>
        <group name="Country 1" footerPosition="ForceAtBottom">
            <groupExpression><![CDATA[$F{Country}]]></groupExpression>
            <groupHeader>
                <band height="52">
                    <textField>
                        <reportElement x="180" y="0" width="200" height="52" uuid="ecbaf5bf-be63-4f90-930c-dabb2c385d33"/>
                        <textElement textAlignment="Center">
                            <font size="35"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
                    </textField>
                </band>
            </groupHeader>
            <groupFooter>
                <band height="20">
                    <textField>
                        <reportElement x="180" y="0" width="200" height="20" uuid="fc3ccc02-ea1b-4aa3-84d0-e40ba46f3966"/>
                        <textElement textAlignment="Center">
                            <font size="10"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
                    </textField>
                </band>
            </groupFooter>
        </group>
        <group name="Country 2">
            <groupExpression><![CDATA[$F{Country}]]></groupExpression>
            <groupFooter>
                <band height="20">
                    <textField>
                        <reportElement x="180" y="0" width="200" height="20" uuid="fb7c7dad-07c1-428d-873e-cb1eae0c00d7"/>
                        <textElement textAlignment="Center">
                            <font size="14"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
                    </textField>
                </band>
            </groupFooter>
        </group>
        <detail>
            <band height="30">
                <textField>
                    <reportElement x="180" y="0" width="365" height="30" uuid="8edf2d40-c8e5-40d0-9bcd-3051581e7acb"/>
                    <textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="0" y="0" width="170" height="30" uuid="4fa050bf-8bbb-47ce-8108-6e9ba25ac668"/>
                    <textFieldExpression><![CDATA[$F{ContactName}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
    </jasperReport>