Jasper使用spring mvc报告SUM函数的编译错误 [英] Jasper reports compile error for SUM function with spring mvc

查看:240
本文介绍了Jasper使用spring mvc报告SUM函数的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using jasper reports to generate reports from my spring mvc application.

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

It works fine as long as I do not use any math functions in jasper report. For example the SUM function in jasper reports gives me a compile time error on my application -

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报告中的字段。

Here is the field from jasper reports.

<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函数,并且必须在服务器上进行计算?如果是这样,那么如何计算报告每页的小计?

Does this mean that I cannot use Jasper functions in the report and the calculations must be done on server? If so, then how do I calculate subtotals for each page of the report?.

推荐答案

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

I solved this problem by creating a variable that calculates the SUM of the required field -

<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>

这是有效的,因为在编译和填充报告后会对变量进行评估。

This works because variables are evaluated after the report is compiled and populated.

这篇关于Jasper使用spring mvc报告SUM函数的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆