试试这样
Dim t As Table = Tables("融资组合查询_TABLE1")
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 = "备案单位"
Dim TotalOn As String = ""
For Each c As Col In t.cols
If c.name.StartsWith("还款金额_") Then
totalOn &= c.name & ","
End If
Next
g.TotalOn = TotalOn & "合计"
'g.TotalOn = "还款金额_1,还款金额_2,还款金额_3,还款金额_4,还款金额_5,还款金额_6,还款金额_7,还款金额_8,还款金额_9,还款金额_10,还款金额_11,还款金额_12,合计"
g.Caption = "{0} 小计"
t.SubtotalGroups.Add(g)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
For Each c As Col In t.cols
If c.name.StartsWith("还款金额_") Then
totalOn &= c.name & ","
End If
Next
g.TotalOn = TotalOn & "合计"
'g.TotalOn = "还款金额_1,还款金额_2,还款金额_3,还款金额_4,还款金额_5,还款金额_6,还款金额_7,还款金额_8,还款金额_9,还款金额_10,还款金额_11,还款金额_12,合计"
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.Subtotal()