Jasper reports JasperReports:条件样式错误“;未找到参数";?

Jasper reports JasperReports:条件样式错误“;未找到参数";?,jasper-reports,Jasper Reports,我想在我的一个报告中使用条件样式来根据条件更改颜色,但它根本不起作用 我尝试将其与,一起使用,并且在所有情况下,我都会得到相同的错误: (参数、字段或变量)未找到 以下是我的代码JRXML: <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001

我想在我的一个报告中使用条件样式来根据条件更改颜色,但它根本不起作用

我尝试将其与
一起使用,并且在所有情况下,我都会得到相同的错误:

(参数、字段或变量)未找到

以下是我的代码JRXML:

<?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="UserDepart" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="15289120-bdf0-4edd-905c-647999c3c0cc">
    <property name="net.sf.jasperreports.style.evaluation.time.enabled" value="true"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#00FFFF">
        <box>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <!-- Here Is The Probleme !!! -->
    <style name="table_CH" mode="Opaque" backcolor="#FF6666">
        <box>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
        </box>
        <conditionalStyle>
            <conditionExpression><![CDATA[$P{color}.equalsIgnoreCase( "o" )]]></conditionExpression>
            <style/>
        </conditionalStyle>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="New Dataset 1" uuid="2c012e5d-0895-4ef1-8b47-20fd8c6b281f">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="nom" class="java.lang.String"/>
        <field name="prenom" class="java.lang.String"/>
        <field name="profil" class="java.lang.String"/>
        <field name="tauxCorrect" class="java.lang.Float"/>
        <field name="progres" class="java.lang.Long"/>
    </subDataset>
    <parameter name="DS1" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <parameter name="logo" class="java.lang.Object" isForPrompting="false"/>
    <!-- Here Is The Parameter i'm using !!! -->
    <parameter name="color" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="departement" class="java.lang.String"/>
    <variable name="colorVar" class="java.lang.String">
        <variableExpression><![CDATA[$P{color}]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="42" splitType="Stretch">
            <image>
                <reportElement x="1" y="1" width="127" height="21" uuid="d12193fc-3939-4a94-81c9-28f6e648566a"/>
                <imageExpression><![CDATA["C:\\Icons\\logo.png"]]></imageExpression>
            </image>
            <image>
                <reportElement x="388" y="0" width="167" height="32" uuid="4f149815-5c04-4b13-a520-e30202556d92"/>
                <imageExpression><![CDATA[$P{logo}]]></imageExpression>
            </image>
        </band>
    </title>
    <pageHeader>
        <band height="51" splitType="Stretch">
            <textField>
                <reportElement x="419" y="0" width="136" height="30" uuid="efb55c6b-c6b5-4855-8111-fc621e280922"/>
                <textElement>
                    <font size="18"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{departement}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="1" y="0" width="418" height="30" uuid="54fd910a-b9ab-441a-b7e5-a332f67b0504"/>
                <textElement>
                    <font size="18"/>
                </textElement>
                <text><![CDATA[Etat d'avancement des utilisateurs du département :]]></text>
            </staticText>
        </band>
    </pageHeader>
    <detail>
        <band height="151" splitType="Stretch">
            <componentElement>
                <reportElement key="table" style="table" x="2" y="2" width="552" height="147" uuid="1e15cf18-8adf-4bad-9339-04deb8240c82"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" whenNoDataType="AllSectionsNoDetail">
                    <datasetRun subDataset="New Dataset 1" uuid="5ccdd061-c1c3-46a0-bc92-af14bda9b14a">
                        <datasetParameter name="REPORT_DATA_SOURCE">
                            <datasetParameterExpression><![CDATA[$P{DS1}]]></datasetParameterExpression>
                        </datasetParameter>
                    </datasetRun>
                    <jr:column width="104" uuid="faddf5bb-759d-4efc-9a3e-9cf16b8cbda2">
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="104" height="30" uuid="795dac43-0ff0-482c-89a0-7dac3b27d513"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <text><![CDATA[Nom]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement x="0" y="0" width="104" height="30" uuid="195d51a0-9e45-4201-ad67-d3026ce2e72c"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{nom}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="111" uuid="8a8bc20b-f8b4-45a6-9cbd-68b4a7391426">
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="111" height="30" uuid="795dac43-0ff0-482c-89a0-7dac3b27d513"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <text><![CDATA[Prenom]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement x="0" y="0" width="111" height="30" uuid="195d51a0-9e45-4201-ad67-d3026ce2e72c"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{prenom}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="102" uuid="657d2155-3e2f-4f41-ba0a-a17a76598491">
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="102" height="30" uuid="795dac43-0ff0-482c-89a0-7dac3b27d513"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <text><![CDATA[Profil]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement x="0" y="0" width="102" height="30" uuid="195d51a0-9e45-4201-ad67-d3026ce2e72c"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{profil}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="131" uuid="d36e39c4-8408-4f2f-865f-787aa3166a7e">
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="1" y="0" width="130" height="30" uuid="795dac43-0ff0-482c-89a0-7dac3b27d513"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <text><![CDATA[Taux de réponses correctes]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement x="0" y="0" width="131" height="30" uuid="195d51a0-9e45-4201-ad67-d3026ce2e72c"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{tauxCorrect}+" %"]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="103" uuid="d36e39c4-8408-4f2f-865f-787aa3166a7e">
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="103" height="30" uuid="795dac43-0ff0-482c-89a0-7dac3b27d513"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <text><![CDATA[Progression Moyenne]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement x="0" y="0" width="103" height="30" uuid="195d51a0-9e45-4201-ad67-d3026ce2e72c"/>
                                <textElement>
                                    <font size="10"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{progres}+" %"]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>

我做错了什么吗?

问题是,您使用的是
中使用
的样式,因此您无法直接访问主报表参数,您需要在此
子数据集中创建参数

<subDataset name="New Dataset 1" uuid="2c012e5d-0895-4ef1-8b47-20fd8c6b281f">
    <parameter name="color" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="nom" class="java.lang.String"/>
    <field name="prenom" class="java.lang.String"/>
    <field name="profil" class="java.lang.String"/>
    <field name="tauxCorrect" class="java.lang.Float"/>
    <field name="progres" class="java.lang.Long"/>
</subDataset>

这是完整的stacktrace吗?您需要错误stacktrace吗?或者你的意思是这是完整的代码?如果你的意思是第二个,那么是的,这是完整的代码。这是你的模板出了问题。我用你的模板重现了这个问题。之后,我删除了参数
color
,并再次创建它。现在一切都好了。也许是编码的问题。。。也许名字的一部分是用英语写的,另一部分是用另一种语言写的(西班牙语?)。它就像一个符咒:),但我现在有一个新的错误,它不会使sens
错误计算表达式:源文本:$P{color}.equalsIgnoreCase(“o”)
中如果$P{color}为空,它可能会有.equalsIgnoreCase($P{color})
<subDataset name="New Dataset 1" uuid="2c012e5d-0895-4ef1-8b47-20fd8c6b281f">
    <parameter name="color" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="nom" class="java.lang.String"/>
    <field name="prenom" class="java.lang.String"/>
    <field name="profil" class="java.lang.String"/>
    <field name="tauxCorrect" class="java.lang.Float"/>
    <field name="progres" class="java.lang.Long"/>
</subDataset>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" whenNoDataType="AllSectionsNoDetail">
    <datasetRun subDataset="New Dataset 1" uuid="7fc961fa-4d60-4d02-8145-f6cbfb54cc10">
        <datasetParameter name="REPORT_DATA_SOURCE">
            <datasetParameterExpression><![CDATA[$P{DS1}]]></datasetParameterExpression>
        </datasetParameter>
        <datasetParameter name="color">
           <datasetParameterExpression><![CDATA[$P{color}]]></datasetParameterExpression>
        </datasetParameter>
    </datasetRun>
    ....
</jr:table>