2014-03-26 96 views
0

我将在Jasper Report中获取整个字段的总和。我从Java代码中传递JRTableModelDataSource如何获得整场的总和?

Unit Price | Quantity 
    100.00  |  5  
    150.00  |  2 
    200.00  |  4 

我在我的报告采用现场打印这些值。

田间表现

$F{Unit Price}*$F{Quantity}(This is the variable named '$V{MUL}') 

和它打印

500.00 
300.00 
800.00 

现在我需要打印所有这些值诸如总和,

500.00 
300.00 
800.00 
------ 
1600.00 

我需要在我的报告中打印此1600.00(Sum of entire Field)。 我试过这个,

SUM($V{MUL}) 
    $V{MUL} is the variable that of multiplied values(500.00,300.00,800.00) 

但是我得到一个错误。这是可能做到或我该怎么做?

回答

0

如下图所示

<variable name="GrpAmount" class="java.math.BigDecimal" resetType="Group" resetGroup="keyType" calculation="Sum"> 
     <variableExpression><![CDATA[$F{Unit Price}*$F{Quantity}]]></variableExpression> 
    </variable> 
你可以做