iReport错误评估表达式

时间:2013-02-20 23:36:10

标签: java xml ireport

我们正在使用iReport 5.0.1,并已成功转换了许多Crystal Reports包。

我正在使用整数和双数据类型混合的数据,我在详细信息部分的变量字段中执行计算。

然后我有3个变量来汇总详细数据。第一个变量是它上面的细节变量的直接和。第二个添加一个参数或第二个参数,具体取决于IF..THEN..ELSE语句,第三个根据类似的IF..THEN..ELSE语句减去相同的参数值。

我需要对Group Footer中的3个变量字段进行舍入,因此我将Math.round(variable_name)应用于3个变量中的每一个。原始的和最后一个(减去参数)都可以完美地工作。中间变量(添加参数)会抛出错误“错误评估表达式:Math.round(variable_name)”。如果我取出格式,它运行正常。

我已经复制并粘贴了工作变量,将其重命名为正确的名称,以确保我不会错过我最初设置它们的方式,但无济于事。当我使用空数据源运行它时,它会运行,但当然没有数据。

这会让我相信数据存在问题,但我已经检查了整个数据,数据对数据源都是有效的,没有NULL,空白或字符数据。

我在这一点上很难过。该报告在Crystal Reports中编译和运行得很好,使用非常接近相同的函数。

如果有人有任何建议,我很乐意倾听,我正在发布以下报告的XML。

提前感谢您提供任何帮助。

微米。斯奈德

    <?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="MarginRequirement"         language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20"         rightMargin="20" topMargin="20" bottomMargin="20" uuid="70f7c2ab-dba2-420a-98b9-        dc041beb65a7">
        <property name="ireport.zoom" value="1.0"/>
        <property name="ireport.x" value="0"/>
        <property name="ireport.y" value="0"/>
        <property name="ireport.jasperserver.reportUnit"         value="/reports/Risk_Management/MarginRequirement"/>
        <property name="ireport.jasperserver.url"         value="http://reports.beefnw.com/jasperserver/services/repository"/>
<parameter name="LCF" class="java.lang.Float">
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression>
</parameter>
<parameter name="LCO" class="java.lang.Float">
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression>
</parameter>
<parameter name="FCF" class="java.lang.Float">
    <defaultValueExpression><![CDATA[0.00]]></defaultValueExpression>
</parameter>
<parameter name="FCO" class="java.lang.Float">
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression>
</parameter>
<parameter name="GF" class="java.lang.Float">
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression>
</parameter>
<parameter name="GO" class="java.lang.Float">
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression>
</parameter>
<queryString>
    <![CDATA[select *,
    if (mid(symbol,-3,1) in("F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"),         "Future", "Option") AS type from margin_requirements
    order by location, clearing_house
    ]]>
</queryString>
<field name="open_price" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="equity" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="close_price" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="open_total_value" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="close_total_value" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="liquidating_value" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="commission" class="java.lang.Float">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="account_id" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="position_id" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="id" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="contract_weight" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="contracts" class="java.lang.Integer">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="account_name" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="account_number" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="location" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="clearing_house" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="type" class="java.lang.String"/>
<field name="group" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="symbol" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="fill_date" class="java.sql.Date">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="updated_at" class="java.sql.Timestamp">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="created_at" class="java.sql.Timestamp">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>
<variable name="loc_clHouse" class="java.lang.String" resetType="None">
    <variableExpression><![CDATA[$F{location} + " - " + $F{clearing_house}]]></variableExpression>
</variable>
<variable name="LC_Orig" class="java.lang.Float" resetType="None">
    <variableExpression><![CDATA[$F{group}=="LIVE_CATTLE"?((($F{contracts}*$F{contract_weight}*$F{open_price})/100)*-1) + (($F{contracts}*$F{contract_weight}*$F{close_price})/100):0.0]]></variableExpression>
</variable>
<variable name="LCOrig_Total" class="java.lang.Float" resetType="Group" resetGroup="ClearingHouse" calculation="Sum">
    <variableExpression><![CDATA[Math.round($V{LC_Orig})]]></variableExpression>
</variable>
<variable name="Suppression" class="java.lang.String" resetType="None">
    <variableExpression><![CDATA["NO"]]></variableExpression>
</variable>
<variable name="LCUpPrice" class="java.lang.Float" resetType="None">
    <variableExpression><![CDATA[$F{type}=="Future"?$F{close_price}+$P{LCF}:$F{close_price}+$P{LCO}]]></variableExpression>
</variable>
<variable name="LCDownPrice" class="java.lang.Float" resetType="None">
    <variableExpression><![CDATA[$F{type}=="Future"?$F{close_price}-$P{LCF}:$P{LCO} > $F{close_price}?0.0:$F{close_price}-$P{LCO}]]></variableExpression>
</variable>
<variable name="LC_Decrease" class="java.lang.Float" resetType="None">
    <variableExpression><![CDATA[$F{group}=="LIVE_CATTLE"?((($F{contracts}*$F{contract_weight}*$F{open_price})/100)*-1)+(($F{contracts}*$F{contract_weight}*$V{LCDownPrice})/100):0.0]]></variableExpression>
</variable>
<variable name="LCDecr_Total" class="java.lang.Float" resetType="Group" resetGroup="ClearingHouse" calculation="Sum">
    <variableExpression><![CDATA[Math.round($V{LC_Decrease})]]></variableExpression>
</variable>
<variable name="LCIncr_Total" class="java.lang.Float" resetType="Group" resetGroup="ClearingHouse" calculation="Sum">
    <variableExpression><![CDATA[Math.round($V{LC_Increase})]]></variableExpression>
</variable>
<variable name="LC_Increase" class="java.lang.Float" resetType="None">
    <variableExpression><![CDATA[$F{group}=="LIVE_CATTLE"?((($F{contracts}*$F{contract_weight}*$F{open_price})/100)*-1)+(($F{contracts}*$F{contract_weight}*$V{LCUpPrice})/100):0.0]]></variableExpression>
</variable>
<group name="ClearingHouse">
    <groupExpression><![CDATA[$V{loc_clHouse}]]></groupExpression>
    <groupHeader>
        <band height="25">
            <printWhenExpression><![CDATA[$V{Suppression}=="YES"]]></printWhenExpression>
            <textField>
                <reportElement uuid="51b78c4d-3747-4282-8b9f-17be6f84feea" x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{loc_clHouse}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="ad970881-452b-42aa-bb9f-a19e735643c5" x="179" y="5" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{Suppression}]]></textFieldExpression>
            </textField>
        </band>
    </groupHeader>
    <groupFooter>
        <band height="116">
            <textField>
                <reportElement uuid="79587964-7211-4761-9221-0c063a1aebf0" x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$V{loc_clHouse}]]></textFieldExpression>
            </textField>
            <textField pattern="¤ #,##0.00">
                <reportElement uuid="3bd9ce71-5cf4-4ae3-b678-8f3942fc9e7a" x="100" y="0" width="100" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$V{LCOrig_Total}]]></textFieldExpression>
            </textField>
            <textField pattern="¤ #,##0.00">
                <reportElement uuid="20ef4729-88b0-4ab2-a5a6-56594bb716d5" x="100" y="40" width="100" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$V{LCDecr_Total}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="16a8b6f9-5e24-4ee6-9e84-e2730d78dea1" x="100" y="20" width="100" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$V{LCIncr_Total}]]></textFieldExpression>
            </textField>
        </band>
    </groupFooter>
</group>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="79" splitType="Stretch"/>
</title>
<pageHeader>
    <band height="142" splitType="Stretch">
        <image>
            <reportElement uuid="eef5e5ab-7b5d-4f86-a20f-5dd51bbd56bd" x="5" y="4" width="310" height="93"/>
            <imageExpression><![CDATA["/home/marlin/bnw_logo_trans.gif"]]></imageExpression>
        </image>
        <rectangle>
            <reportElement uuid="957ac037-7238-46e1-809c-4ded5f76b72b" x="0" y="102" width="572" height="38" forecolor="#E6D8AB" backcolor="#E6D8AB"/>
        </rectangle>
        <staticText>
            <reportElement uuid="3b2925af-f556-4c0c-84bb-e5b5b021128e" x="126" y="110" width="341" height="30"/>
            <textElement textAlignment="Center">
                <font size="18" isBold="true"/>
            </textElement>
            <text><![CDATA[MARGIN REQUIREMENT REPORT]]></text>
        </staticText>
    </band>
</pageHeader>
<columnHeader>
    <band height="27" splitType="Stretch">
        <rectangle>
            <reportElement uuid="a2f2bf6a-6f14-48e5-9d19-5f153caed5a5" x="0" y="0" width="572" height="27" forecolor="#E6D8AB" backcolor="#E6D8AB"/>
        </rectangle>
    </band>
</columnHeader>
<detail>
    <band height="96" splitType="Stretch">
        <printWhenExpression><![CDATA[$V{Suppression}=="NO"]]></printWhenExpression>
        <textField>
            <reportElement uuid="ed06c6f7-7b44-4033-8c4a-9364d9c22e13" x="100" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$V{LC_Orig}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="55b4791f-dfe7-415c-89d5-ebd937c6a329" x="0" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$V{Suppression}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="aba93e69-1ab0-476a-81e0-c65d8f482233" x="100" y="40" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$V{LC_Decrease}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="6f9026a6-abf5-4017-974c-9e972bed8181" x="0" y="20" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$P{LCF}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="ff53c29d-4006-4b99-8b77-295717483c79" x="0" y="40" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$P{LCO}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement uuid="e305cdbe-e93c-47bb-aedd-f2fc1478e33d" x="100" y="20" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$V{LC_Increase}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<columnFooter>
    <band splitType="Stretch"/>
</columnFooter>
<pageFooter>
    <band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
    <band height="42" splitType="Stretch"/>
</summary>
    </jasperReport>

1 个答案:

答案 0 :(得分:1)