2014-03-26 34 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> 
你可以做