2

crosstabを使用してレポートを実行すると問題が発生します。エラーは次のとおりです。

印刷中にエラーが発生しました... 式の評価エラー: ソース テキスト: $V{cat_code} net.sf.jasperreports.engine.fill.JRExpressionEvalException: 式の評価エラー: ソース テキスト: $V{cat_code}

ソースコードの何が問題なのかを知ることができますか? これは私のコードです:

<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="Corr_ticket" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<?xml version="1.0" encoding="UTF-8"?>
    <import value="com.google.common.base.*"/>
    <style name="Crosstab Data Text" hAlign="Center"/>
    <parameter name="daterangefrom" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="daterangeto" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="monthy" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="yrs" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="quarter" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="weeks" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <queryString>

    </queryString>
    <field name="daterange" class="java.lang.String"/>
    <field name="ticketid" class="java.lang.Integer"/>
    <field name="cat_code" class="java.lang.Integer"/>
    <field name="descategory" class="java.lang.String"/>
    <field name="subcat_code1" class="java.lang.Integer"/>
    <field name="dessub1cat" class="java.lang.String"/>
    <field name="subcat_code2" class="java.lang.Integer"/>
    <field name="dessub2cat" class="java.lang.String"/>
    <field name="description_sub" class="java.lang.String"/>
    <field name="description_source" class="java.lang.String"/>
    <pageHeader>
        <band height="141">
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="0" y="53" width="802" height="35" isRemoveLineWhenBlank="true"/>
                <textElement>
                    <font size="11" isBold="true"/>
                    <paragraph lineSpacing="1_1_2"/>
                </textElement>
                <textFieldExpression><![CDATA[(!Strings.isNullOrEmpty($P{daterangefrom}) && !Strings.isNullOrEmpty($P{daterangeto}) && Strings.isNullOrEmpty($P{weeks}) && Strings.isNullOrEmpty($P{monthy}) && Strings.isNullOrEmpty($P{quarter}) && Strings.isNullOrEmpty($P{yrs})) ? "Date Ticket Created From : " + $P{daterangefrom} +"\n" + "Date Ticket Created to : " + $P{daterangeto}
 : null]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="119" width="100" height="20"/>
                <textElement>
                    <font size="11" isBold="true"/>
                </textElement>
                <text><![CDATA[State :]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="98" width="90" height="20"/>
                <textElement>
                    <font size="11" isBold="true"/>
                </textElement>
                <text><![CDATA[Industry Group :]]></text>
            </staticText>
        </band>
    </pageHeader>
    <summary>
        <band height="297">
            <crosstab>
                <reportElement x="0" y="0" width="802" height="297"/>
                <rowGroup name="ticketid" width="70" totalPosition="End">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{ticketid}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents backcolor="#F0F8FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="25"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$V{ticketid}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents backcolor="#BFE1FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="70" height="25"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Total ticketid]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <columnGroup name="cat_code" height="30" totalPosition="End">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{cat_code}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents backcolor="#F0F8FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isBlankWhenNull="true">
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="100" height="30"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$V{cat_code}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents backcolor="#005FB3" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="50" height="60" forecolor="#FFFFFF"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Total cat_code]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <columnGroup name="description_source" height="30" totalPosition="End">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{description_source}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents backcolor="#F0F8FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="30"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$V{description_source}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents backcolor="#BFE1FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="50" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Total description_source]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <measure name="description_sourceMeasure" class="java.lang.Integer" calculation="Count">
                    <measureExpression><![CDATA[$F{description_source}]]></measureExpression>
                </measure>
                <crosstabCell width="50" height="25">
                    <cellContents>
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
                            <textElement/>
                            <textFieldExpression><![CDATA[$V{description_sourceMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell height="25" rowTotalGroup="ticketid">
                    <cellContents backcolor="#BFE1FF" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
                            <textElement/>
                            <textFieldExpression><![CDATA[$V{description_sourceMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="50" columnTotalGroup="cat_code">
                    <cellContents backcolor="#005FB3" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25" forecolor="#FFFFFF"/>
                            <textElement/>
                            <textFieldExpression><![CDATA[$V{description_sourceMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell rowTotalGroup="ticketid" columnTotalGroup="cat_code">
                    <cellContents backcolor="#005FB3" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25" forecolor="#FFFFFF"/>
                            <textElement/>
                            <textFieldExpression><![CDATA[$V{description_sourceMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="50" columnTotalGroup="description_source">
                    <cellContents backcolor="#BFE1FF" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
                            <textElement/>
                            <textFieldExpression><![CDATA[$V{description_sourceMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell rowTotalGroup="ticketid" columnTotalGroup="description_source">
                    <cellContents backcolor="#BFE1FF" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
                            <textElement/>
                            <textFieldExpression><![CDATA[$V{description_sourceMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
            </crosstab>
        </band>
    </summary>
</jasperReport>

その他の問題:- 私のフィールドには field name="cat_code" class="java.lang.Integer" があり、クロスタブの変数にはbucket class="java.lang.String".How があるため、問題は「式クラス」だと思います。この状況を処理するには?

4

1 に答える 1

0

エラー メッセージに示さcat_codeれているような名前の変数がありません。$V{cat_code}次の名前のフィールドがありますcat_code

<field name="cat_code" class="java.lang.Integer"/>

これという名前の変数を定義するのを忘れていると思います。変数セクションを右クリックして をクリックすると、iReport でこれを行うことができますAdd Variable。次に、それをあなたが望むものと定義するだけです。

私はクロス集計を使用したことがないので、これは完全に間違っている可能性があります$F{cat_code}

于 2012-06-18T17:59:36.290 に答える