要单独写代码
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("第一列", Gettype(String), 16)
dtb.AddDef("第二列", Gettype(String), 16)
Dim prds As List(of String) = DataTables("表A").GetValues("第四列", "第四列 is not null")
Dim str As String = ""
Dim cs As String = ""
For Each prd As String In prds
dtb.AddDef(prd, Gettype(Double))
str &= "isnull(" & prd & ",0)+"
cs &= prd & ","
Next
cs &= "合计"
dtb.AddDef("合计", Gettype(Double), str.trim("+"))
dtb.Build()
For Each cus As String() In DataTables("表A").GetValues("第一列|第二列")
Dim dr As DataRow = DataTables("统计").AddNew()
dr("第一列") = cus(0)
dr("第二列") = cus(1)
For Each prd As String In prds
dr(prd) = DataTables("表A").Compute("count(第一列)", "第一列 = '" & cus(0) & "' And 第二列 = '" & cus(1) & "' and 第四列 = '" & prd & "'")
Next
Next
Dim t As Table = Tables("统计")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "第一列"
g.TotalOn = cs
g.Caption = "{0} 小计"
t.SubtotalGroups.Add(g)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = cs
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.Subtotal()
MainTable = t