2011-09-16 46 views
0

我創建了一個包含十進制值的支付列的jasper報告(格式爲 新的DecimalFormat(「$#,## 0.00」)。format($ F(paid)) )。在報告底部,我生成了該付費欄的總餘額。當我想將報告導出爲ex​​cel時,它會給出總和問題。在Excel表格中,總和沒有顯示(由於新的DecimalFormat(「$#,## 0.00」)。格式($ F(付費)),它返回String值)。所以,任何人都請給我解決方案。我想在Excel中顯示付費值的總和。將jasper報告導出爲ex​​cel - 2003,2007

感謝&問候 SRINIVAS

+0

是否所有細胞的Excel文件(列付費)具有數字格式? –

+0

其字符串格式就像這樣$ 1234.45。在Excel中,單元格不支持字符串。 – java2world

回答

0

你可以嘗試這樣的事情:

<queryString> 
     <![CDATA[SELECT ... AS paid FROM...]]> 
</queryString> 
... 
<field name="paid" class="java.math.BigDecimal"/> 
<variable name="sum" class="java.math.BigDecimal" calculation="Sum"> 
    <variableExpression><![CDATA[$F{paid}]]></variableExpression> 
</variable> 
... 
<detail> 
    <band height="39" splitType="Stretch"> 
     <textField> 
     <reportElement x="170" y="15" width="100" height="20"/> 
     <textElement/> 
     <textFieldExpression><![CDATA[$F{paid}]]></textFieldExpression> 
     </textField> 
    </band> 
</detail> 
... 
<summary> 
    <band height="42" splitType="Stretch"> 
     <textField pattern="$#,##0.00"> 
      <reportElement x="182" y="11" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$V{sum}]]></textFieldExpression> 
     </textField> 
     <staticText> 
      <reportElement x="82" y="11" width="100" height="20"/> 
      <textElement/> 
      <text><![CDATA[Total:]]></text> 
     </staticText> 
    </band> 
</summary> 
+0

非常感謝你非常有幫助的meee – java2world