Dim bd1 As New GroupTableBuilder("统计表B1",DataTables("材料入库登记"))
bd1.Groups.AddDef("项目分类")
bd1.Groups.AddDef("内容","成本类型")
bd1.Totals.AddDef("成本分离_成本金额","投入成本")
bd1.Totals.AddDef("数量")
bd1.Build
Dim bd2 As New GroupTableBuilder("统计表B2",DataTables("项目其他费用支出"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("项目分类")
bd2.Groups.AddDef("内容","成本类型")
bd2.Totals.AddDef("金额","投入成本")
bd2.Build
Dim t1 As Table = Tables("统计表B1")
Dim t2 As Table = Tables("统计表B2")
For Each r As Row In t2.rows
Dim nr As Row = t1.addnew
nr("项目分类") = r("项目分类")
nr("成本类型") = r("成本类型")
nr("投入成本") = r("投入成本")
Next
With t1
.MergeMode = MergeModeEnum.Standard
.MergeCols.Clear()
.MergeCols.Add("项目分类")
.MergeCols.Add("成本类型")
.MergeSort = "项目分类"
.AllowMerge = True
End With
Dim g As Subtotalgroup
t1.SubtotalGroups.Clear()
t1.GroupAboveData = False
t1.TreeVisible = False
t1.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "数量,投入成本"
g.Caption = "总计"
t1.SubtotalGroups.Add(g)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "项目分类"
g.TotalOn = "数量,投入成本"
g.Caption = "{0} 小计"
t1.SubtotalGroups.Add(g)
t1.Subtotal()
MainTable = t1
'以下显示格式
t1.cols("数量").DataCol.setFormat("#,###.00")
t1.cols("投入成本").DataCol.setFormat("#,###.00")