按[汇总]按钮得到了我想要的结果(如图)但提示代码出错,查了半天不知错在哪
【汇总】按钮代码
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.Upto = True
g.TotalOn = "入仓_数量,出仓_数量"
g.Caption = "{0}月合计"
t.SubtotalGroups.Add(g)
t.Sort = "日期"
t.Subtotal(True)
Dim r As Row
Static s As String
Dim s1 As String
Dim n As Double
For i As Integer = 0 To Tables("材料帐页").Rows.Count(True) - 1
r = Tables("材料帐页").Rows(i,True)
If r.IsGroup
s1 = r("汇总").Split(" ")(0) & " " & r("汇总").Split(" ")(1)
r("材料") = r("汇总")
If s = "" OrElse s1 <> s Then
n = r("入仓_数量") - R("出仓_数量")
r("库存_数量") = n
Else
n + = r("入仓_数量") - R("出仓_数量")
r("库存_数量") = n
End If
s = s1
End If
Next