Dim g As New GroupTableBuilder("库存表", DataTables("例子二")) g.Groups.AddDef("产品") g.Totals.AddDef("库存") g.Build() Dim dt As DataTable = DataTables("例子二") For Each dr As DataRow In DataTables("库存表").DataRows dr("库存") = dt.Compute("Sum(入库)","产品 = '" & dr("产品") & "'") - dt.Compute("Sum(出库)","产品 = '" & dr("产品") & "'") Next