wie Sie Datensätze Sortieren einer Spalte in jasper report

Arbeite ich an Jasper ireport tool. Ich bin immer Datensätze aus der Tabelle, aber ich wollte die Datensätze Sortieren. - Ob ich tun, das Sortieren im java code, oder wir tun es im tool selbst bin ich nicht immer. also bitte helft mir, wie kann ich Sortieren. Vielen Dank im Voraus.

<?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="Myreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7a6aa9cf-834e-4433-bf00-09da542cedcf">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/>
    <style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/>
    <style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true" pdfFontName="Times-Roman"/>
    <style name="Detail" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"/>
    <style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
        <conditionalStyle>
            <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
            <style mode="Opaque" backcolor="#F0EFEF"/>
        </conditionalStyle>
    </style>
    <queryString language="SQL">
        <![CDATA[select * from ireport;]]>
    </queryString>
    <field name="Username" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Empnumber" class="java.math.BigDecimal">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="dept" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="organisation" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Designation" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="dateOfCreation" class="java.sql.Date">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <sortField name="Username"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="132" splitType="Stretch">
            <frame>
                <reportElement mode="Opaque" x="0" y="0" width="451" height="95" backcolor="#000000" uuid="2936018d-2b8a-4dc5-9cd1-f40670680e7f"/>
                <staticText>
                    <reportElement style="Title" x="0" y="0" width="370" height="66" uuid="f1a20926-1f5e-4b58-aca4-443c2693a2d9"/>
                    <textElement>
                        <font isBold="false"/>
                    </textElement>
                    <text><![CDATA[COGXAR]]></text>
                </staticText>
                <staticText>
                    <reportElement style="SubTitle" x="157" y="66" width="249" height="29" uuid="f3292300-bafd-40a9-bed3-e60684e263a1"/>
                    <textElement>
                        <font size="22" isBold="false"/>
                    </textElement>
                    <text><![CDATA[Cogxarian]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement mode="Opaque" x="0" y="100" width="451" height="32" forecolor="#000000" backcolor="#CC0000" uuid="3f5100f2-6886-440b-b495-428750dd9274"/>
                <textField pattern="EEEEE dd MMMMM yyyy">
                    <reportElement x="307" y="12" width="144" height="20" forecolor="#FFFFFF" uuid="1cafc436-89d2-4ca3-b1a4-41b6a5f1d684"/>
                    <textElement textAlignment="Right">
                        <font size="12"/>
                    </textElement>
                    <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="26" splitType="Stretch">
            <staticText>
                <reportElement style="Column header" x="0" y="7" width="92" height="18" forecolor="#000000" uuid="c663f7b2-b7b7-493a-822d-72ad6b74d24a"/>
                <textElement>
                    <font isBold="false"/>
                </textElement>
                <text><![CDATA[Username]]></text>
            </staticText>
            <staticText>
                <reportElement style="Column header" x="92" y="7" width="92" height="18" forecolor="#000000" uuid="f550db3a-3e20-4955-8197-fa0b71f95ac0"/>
                <textElement>
                    <font isBold="false"/>
                </textElement>
                <text><![CDATA[Empnumber]]></text>
            </staticText>
            <staticText>
                <reportElement style="Column header" x="184" y="7" width="92" height="18" forecolor="#000000" uuid="0f22eeff-a2ba-4e2f-8c7e-087305844079"/>
                <textElement>
                    <font isBold="false"/>
                </textElement>
                <text><![CDATA[dept]]></text>
            </staticText>
            <staticText>
                <reportElement style="Column header" x="276" y="7" width="92" height="18" forecolor="#000000" uuid="050a8043-0089-4496-8cf7-80aeca305866"/>
                <textElement>
                    <font isBold="false"/>
                </textElement>
                <text><![CDATA[organisation]]></text>
            </staticText>
            <staticText>
                <reportElement style="Column header" x="368" y="7" width="92" height="18" forecolor="#000000" uuid="ca99e045-3117-425f-b918-57fac68acc13"/>
                <textElement>
                    <font isBold="false"/>
                </textElement>
                <text><![CDATA[Designation]]></text>
            </staticText>
            <staticText>
                <reportElement style="Column header" x="460" y="7" width="92" height="18" forecolor="#000000" uuid="88f8eb45-00ae-476e-a4a7-d451fff93608"/>
                <textElement>
                    <font isBold="false"/>
                </textElement>
                <text><![CDATA[dateOfCreation]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="18" splitType="Stretch">
            <frame>
                <reportElement style="Row" mode="Opaque" x="0" y="0" width="555" height="18" uuid="0105b77c-fd98-4b2e-9b1a-229de1e56889"/>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Detail" positionType="Float" x="0" y="0" width="92" height="18" uuid="5b41779b-5b12-4843-be95-c2092e86859b"/>
                    <textElement>
                        <font size="14"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{Username}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Detail" positionType="Float" x="92" y="0" width="92" height="18" uuid="0a87e452-d44b-463e-9e29-67934e9561db"/>
                    <textElement>
                        <font size="14"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{Empnumber}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Detail" positionType="Float" x="184" y="0" width="92" height="18" uuid="a669140e-e1b8-4dad-8821-9ddb2b1d4c7d"/>
                    <textElement>
                        <font size="14"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{dept}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Detail" positionType="Float" x="276" y="0" width="92" height="18" uuid="c4cb3a09-f100-4c53-898a-9513decc43be"/>
                    <textElement>
                        <font size="14"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{organisation}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Detail" positionType="Float" x="368" y="0" width="92" height="18" uuid="de6e6deb-6a26-4ee0-9dd4-e11f446e1d56"/>
                    <textElement>
                        <font size="14"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{Designation}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Detail" positionType="Float" x="460" y="0" width="92" height="18" uuid="a4dd4dd7-682b-43f2-80f6-d84eea5fd001"/>
                    <textElement>
                        <font size="14"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{dateOfCreation}]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </detail>
    <columnFooter>
        <band height="142" splitType="Stretch">
            <line>
                <reportElement positionType="FixRelativeToBottom" x="0" y="3" width="555" height="1" uuid="d472bee8-7d59-46f2-a9ca-1adad4b8f0f9"/>
                <graphicElement>
                    <pen lineWidth="0.5" lineColor="#999999"/>
                </graphicElement>
            </line>
        </band>
    </columnFooter>
    <pageFooter>
        <band height="160" splitType="Stretch">
            <frame>
                <reportElement mode="Opaque" x="0" y="1" width="555" height="24" forecolor="#D0B48E" backcolor="#000000" uuid="53c76dd1-ef10-49a4-a80c-729f04a2b5aa"/>
                <textField evaluationTime="Report">
                    <reportElement style="Column header" x="513" y="0" width="40" height="20" forecolor="#FFFFFF" uuid="390b5016-5c20-479f-9aee-40b0ba966798"/>
                    <textElement verticalAlignment="Middle">
                        <font size="10" isBold="false"/>
                    </textElement>
                    <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement style="Column header" x="433" y="0" width="80" height="20" forecolor="#FFFFFF" uuid="1ee577c5-d775-4b82-a3c5-c28b48fe5b8b"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font size="10" isBold="false"/>
                    </textElement>
                    <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
                </textField>
                <textField pattern="EEEEE dd MMMMM yyyy">
                    <reportElement style="Column header" x="2" y="1" width="197" height="20" forecolor="#FFFFFF" uuid="4272ffa9-1561-453a-b52c-9f2415d9583a"/>
                    <textElement verticalAlignment="Middle">
                        <font size="10" isBold="false"/>
                    </textElement>
                    <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>
  • können Sie passen Sie Ihre sql ? wählen Sie * von ireport order by column_name
InformationsquelleAutor user2983424 | 2013-11-12
Schreibe einen Kommentar