Dim bd1 As New GroupTableBuilder("统计表B1",DataTables("材料入库登记"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("项目分类")
bd1.Groups.AddDef("内容","成本类型")
bd1.Totals.AddDef("成本分离_成本金额","投入成本")
bd1.Totals.AddDef("数量")
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表B2",DataTables("项目其他费用支出"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("项目分类")
bd2.Groups.AddDef("内容","成本类型")
bd2.Totals.AddDef("金额","投入成本")
dt2 = bd2.BuildDataSource()
Dim arr() As String = {"项目分类","成本类型"}
dt1.Combine(arr,dt2,arr)
dt1.show("统计表B") '将统计结果绑定到Table
Dim t As Table = Tables("统计表B")
With Tables("统计表B")
.MergeMode = MergeModeEnum.Standard
.MergeCols.Clear()
.MergeCols.Add("项目分类")
.MergeCols.Add("成本类型")
.MergeSort = "项目分类"
.AllowMerge = True
End With
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)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "项目分类"
g.TotalOn = "数量,投入成本"
g.Caption = "{0} 小计"
t.SubtotalGroups.Add(g)
t.Subtotal()
MainTable = t
'以下显示格式
Tables("统计表B").cols("数量").DataCol.setFormat("#,###.00")
Tables("统计表b").cols("投入成本").DataCol.setFormat("#,###.00")
'结束
老师,为什么多出一个“投入成本1”列,我目的是加到“投入成本”列中去。我有二张表取数,内容列为不同成本名称。目的,按项目、成本大类合并到一个统计表中去,求修改代码
此主题相关图片如下:汇总表.png