【问题标题】:Jasper reports compile error for SUM function with spring mvcJasper 使用 spring mvc 报告 SUM 函数的编译错误
【发布时间】:2015-03-12 00:06:45
【问题描述】:

我正在使用 jasper 报告从我的 spring mvc 应用程序生成报告。

只要我不在 jasper 报告中使用任何数学函数,它就可以正常工作。 例如,jasper 报告中的 SUM 函数在我的应用程序上给了我一个编译时错误 -

1. The method SUM(int) is undefined for the type ContentUsageStatisticsReport_1426086372880_332015
                value = SUM(((java.math.BigDecimal)field_cnt.getValue()).intValue()); //$JR_EXPR_ID=15$

这是来自 jasper 报告的字段。

<textField>
            <reportElement x="210" y="1" width="130" height="20" uuid="45fbed39-f63a-41ff-8ff1-88821aeefcd1"/>
            <textFieldExpression><![CDATA[SUM($F{cnt}.intValue())]]></textFieldExpression>
</textField>

这是否意味着我不能在报表中使用 Jasper 函数并且必须在服务器上进行计算?如果是这样,那么我如何计算报告每一页的小计?

【问题讨论】:

    标签: java spring-mvc jasper-reports


    【解决方案1】:

    我通过创建一个变量来计算所需字段的总和解决了这个问题 -

    <variable name="subtotal_of_cnt" class="java.math.BigDecimal" resetType="Group" resetGroup="isALUEmployee" calculation="Sum">
            <variableExpression><![CDATA[$F{cnt}]]></variableExpression>
    </variable>
    

    并使用它-

    <textField>
                        <reportElement x="210" y="1" width="130" height="20" uuid="45fbed39-f63a-41ff-8ff1-88821aeefcd1"/>
                        <textFieldExpression><![CDATA[$V{subtotal_of_cnt}]]></textFieldExpression>
    </textField>
    

    这是可行的,因为变量是在编译和填充报告之后评估的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-28
      • 1970-01-01
      • 2012-05-22
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      相关资源
      最近更新 更多