必须使用辅助列,不想看到辅助列,可以隐藏起来,注意代码开头的三个点,不能省略
'''
Dim t As Table = Tables("窗口1_table1")
If t.DataTable.DataCols.Contains("临时姓名") = False
t.DataTable.DataCols.Add("临时姓名", Gettype(String))
End If
If t.DataTable.DataCols.Contains("临时金额") = False
t.DataTable.DataCols.Add("临时金额", Gettype(Double))
End If
For Each r As Row In t.rows
r(“临时姓名") = r("姓名").replace("(到店)", "")
Next
For Each r As Row In t.rows
r("临时金额") = t.Compute("sum(购买金额)", "姓名 like '%" & r("临时姓名") & "%'")
Next
t.Cols("临时姓名").Visible = False
t.Cols("临时金额").Visible = False
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} 小计"
t.SubtotalGroups.Add(g)
t.sort = "临时金额 desc"
t.Subtotal(True)