Dim t As Table = Tables("表A")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = True
t.TreeVisible = True
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "立项日期"
g.TotalOn = "立项标的"
g.Caption = "{0}月"
g.DateGroup = DateGroupEnum.Month
t.SubtotalGroups.Add(g)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "所属公司"
g.TotalOn = "立项标的"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "立项标的"
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.Subtotal()
Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
r = t.Rows(i,True)
If r.IsGroup '如果是分组行
If r.Level = -1 Then
Dim f As String = ""
Dim v As String = " 总计:" & t.Compute("Count(立项编号)",f)
r("立项编号") = v
ElseIf r.level = 0 Then
Dim f As String = "所属公司 = '" & r("所属公司") & "'"
Dim v As String = " 立项数量:" & t.Compute("Count(立项编号)",f)
r("立项编号") = v
ElseIf r.level = 1 Then
Dim sum As Double = 0
For j As Integer = i+1 To t.Rows.count(True)-1
If t.Rows(j,True).IsGroup Then
Exit For
Else
sum += 1
End If
Next
Dim v As String = " 立项数量:" & sum
r("立项编号") = v
End If
End If
Next