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

Create tables grouped by a category using one dataset


helloterence

Recommended Posts

Hello,

I was wondering if anyone knows how to print seperate tables grouped by a category given one dataset?

For example:

Dataset:

NameDateNum of CoffeesNum of Donuts
John01-Jul23
John08-Aug02
Mike12-Sep12

 

I am looking for my report to be able to print seperate tables grouped by each individual, like so...

John
DateNum of CoffeesNum of Donuts
01-Jul23
08-Aug02

 

Mike
DateNum of CoffeesNum of Donuts
12-Sep12

Any help is appreciated in advanced!

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

<?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="report2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="89f86b24-87cf-4ad5-b343-ae1c7c0f2eb6">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <queryString>
        <![CDATA[select * from dataset]]>
    </queryString>
    <field name="Name" class="java.lang.String"/>
    <field name="Date" class="java.sql.Timestamp"/>
    <field name="NumCoffees" class="java.math.BigDecimal"/>
    <field name="NumDonuts" class="java.lang.String"/>
    <group name="Name">
        <groupExpression><![CDATA[$F{Name}]]></groupExpression>
        <groupHeader>
            <band height="86">
                <textField>
                    <reportElement uuid="2b020496-555e-4f88-92df-fb1d3f3c5fab" x="55" y="46" width="427" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement textAlignment="Center">
                        <font size="12" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement uuid="a92aedb4-490a-4d4f-8792-92a7be0893d2" x="55" y="66" width="169" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <text><![CDATA[Date]]></text>
                </staticText>
                <staticText>
                    <reportElement uuid="b1ed9ea2-2564-4073-9f1f-a98f4056f2e3" x="224" y="66" width="138" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <text><![CDATA[Num of Coffees]]></text>
                </staticText>
                <staticText>
                    <reportElement uuid="107c9050-d08d-4f14-aa1a-76af89cb5409" x="362" y="66" width="120" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <text><![CDATA[Num of Donuts]]></text>
                </staticText>
            </band>
        </groupHeader>
        <groupFooter>
            <band/>
        </groupFooter>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band splitType="Stretch"/>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement uuid="9d952323-4106-4f8a-b793-0700c561d520" x="362" y="0" width="120" height="20"/>
                <box>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement/>
                <textFieldExpression><![CDATA[$F{NumDonuts}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="2459e8fe-648b-4582-91fb-785e80e7d2ae" x="224" y="0" width="138" height="20"/>
                <box>
                    <topPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                </box>
                <textElement/>
                <textFieldExpression><![CDATA[$F{NumCoffees}]]></textFieldExpression>
            </textField>
            <textField pattern="dd-MMM">
                <reportElement uuid="28965c6d-7a6d-468d-82e8-84bde99873e9" x="55" y="0" width="169" height="20"/>
                <box>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement/>
                <textFieldExpression><![CDATA[$F{Date}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>
 

Link to comment
Share on other sites

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...