设置成汇总模式,然后用SaveExcel方法。
Dim t As Table = Tables("表A")
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 = "第四列"
g.Caption = "合计"
t.SubtotalGroups.Add(g)
t.Subtotal()
t.SaveExcel("C:\test.xls","表A")