在临时表增加合计列合计行,已有大神有点甜解决不过现在还有一点小问题,如何初始临时表内有空值,则无法合计,现在我已解决合计行的空值合计,
请问合计列如何解决空值问题,请大神们支招.
以下是我的源码
以下是部分关键代码
Dim dtb As New DataTableBuilder("输入")
Dim scs As List(of String) = DataTables("表A").GetUniqueValues("","颜色")
Dim cms As List(of String) = DataTables("表A").GetUniqueValues("","尺码")
dtb.AddDef("颜色", Gettype(String), 16)
Dim cs As String = ""
For Each cm As String In cms
dtb.AddDef(cm, Gettype(Integer), 16)
If cm = "" Or cm Is Nothing Then cm="0"
cs += cm & "+"
Next
cs = cs.Trim("+")
dtb.AddDef("合计", Gettype(Integer), cs)
Tables("窗口1_Table1").DataSource = dtb .BuildDataSource
For Each sc As String In scs
Dim rw As Row = Tables("窗口1_Table1").AddNew
Dim rs As List(of DataRow) = DataTables("表A").Select("颜色 = '" & sc & "'")
rw("颜色") = sc
For Each r As DataRow In rs
rw(r("尺码")) = r("数量")
Next
Next
Tables("窗口1_Table1").AllowEdit = True
Dim t As Table = Tables("窗口1_Table1")
Dim ndr As Row = t.AddNew
ndr(0) = "合计"
For i As Integer = 1 To t.Cols.Count - 2
ndr(i) = t.Compute("sum(" & t.Cols(i).Name & ")")
Next
[此贴子已经被作者于2013-8-5 11:14:20编辑过]