以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  专业报表小数位数  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=76369)

--  作者:douglas738888
--  发布时间:2015/10/27 18:22:00
--  专业报表小数位数
老师,我在专业报表的代码中加入合计代码后,原来其他列设置的”0.00“代码不显示小数后两位,后删除以下代码又恢复正常,
下面代码如何修改能保证表中显示小数点两位,合计也显示小数点两位

For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))                       
    Next
Next
rt.Rows.Count = rt.Rows.Count + 1
Dim cnt As Integer = rt.Rows.Count - 1
rt.Cells(cnt,0).Text = "收入合计"
For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    If tb.Cols(ColNames(c)).IsNumeric Then
        rt.Cells(cnt,c).Text = tb.Compute("Sum(" & ColNames(c) & ")")
    End If
Next


--  作者:大红袍
--  发布时间:2015/10/27 19:10:00
--  

 

[此贴子已经被作者于2015/10/27 19:10:40编辑过]

--  作者:大红袍
--  发布时间:2015/10/27 19:11:00
--  

For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
    If tb.Cols(ColNames(c)).IsNumeric Then
        rt.Cells(r + 1, c).Text = format(tb.Rows(r)(ColNames(c)),"0.00")
       
    Else
        rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
        End If
    Next
Next
rt.Rows.Count = rt.Rows.Count + 1
Dim cnt As Integer = rt.Rows.Count - 1
rt.Cells(cnt,0).Text = "收入合计"
For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    If tb.Cols(ColNames(c)).IsNumeric Then
        rt.Cells(cnt,c).Text = format(tb.Compute("Sum(" & ColNames(c) & ")"), "0.00")
    End If
Next