-- 作者:有点甜
-- 发布时间:2017/8/13 20:31:00
--
生成统计之后,再设置汇总模式,不就好了?如代码
Dim t As Table = Tables("窗口1_Table1") 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 = "{0} 小计" t.SubtotalGroups.Add(g)
g = New SubtotalGroup g.Aggregate = AggregateEnum.Sum g.GroupOn = "*" g.TotalOn = "预算下达_金额,实际支付_金额,收支_结余" g.Caption = "总计" t.SubtotalGroups.Add(g)
t.Subtotal()
|
-- 作者:有点甜
-- 发布时间:2017/8/13 23:55:00
--
汇总统计的话,只能这样了
Dim t As Table = Tables("窗口1_Table1") Dim g As Subtotalgroup t.SubtotalGroups.Clear() t.GroupAboveData = False t.TreeVisible = False t.SpillNode = False
g = New Subtotalgroup g.Aggregate = AggregateEnum.Sum g.GroupOn = "四级科目" g.TotalOn = "预算下达_金额,实际支付_金额,收支_结余" g.Caption = "{0} 小计" t.SubtotalGroups.Add(g)
g = New Subtotalgroup g.Aggregate = AggregateEnum.Sum g.GroupOn = "三级科目" g.TotalOn = "预算下达_金额,实际支付_金额,收支_结余" g.Caption = "{0} 小计" t.SubtotalGroups.Add(g)
g = New Subtotalgroup g.Aggregate = AggregateEnum.Sum g.GroupOn = "二级科目" g.TotalOn = "预算下达_金额,实际支付_金额,收支_结余" g.Caption = "{0} 小计" t.SubtotalGroups.Add(g)
g = New Subtotalgroup g.Aggregate = AggregateEnum.Sum g.GroupOn = "一级科目" g.TotalOn = "预算下达_金额,实际支付_金额,收支_结余" g.Caption = "{0} 小计" t.SubtotalGroups.Add(g)
t.Subtotal()
For i As Integer = 0 To t.Rows.count(True)-1 Dim r As Row = t.Rows(i, True) If r.IsGroup Then r("资金来源") = Nothing If r.Level = 0 Then r("一级科目") = "总计" ElseIf r.Level = 1 Then r("二级科目") = "合计" ElseIf r.Level = 2 Then r("三级科目") = "合计" ElseIf r.Level = 3 Then r("四级科目") = "小计" End If End If Next
|
-- 作者:有点甜
-- 发布时间:2017/8/14 0:11:00
--
或者,这样写
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("预算统计表")) Dim dt1 As fxDataSource bd1.Groups.AddDef("资金来源") \'根据型号分组 bd1.Groups.AddDef("预算资金性质") \'根据型号分组 bd1.Groups.AddDef("一级科目") \'根据型号分组 bd1.Groups.AddDef("二级科目") \'根据型号分组 bd1.Groups.AddDef("三级科目") \'根据型号分组 bd1.Groups.AddDef("四级科目") \'根据型号分组 bd1.Groups.AddDef("五级科目") \'根据型号分组 bd1.Groups.AddDef("六级科目") \'根据型号分组 bd1.Groups.AddDef("七级科目") \'根据型号分组 bd1.Totals.AddDef("预算下达金额","预算下达_金额") \'对数量进行统计 dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("资金支出统计表")) Dim dt2 As fxDataSource bd2.Groups.AddDef("资金来源") \'根据型号分组 bd2.Groups.AddDef("预算资金性质") \'根据型号分组 bd2.Groups.AddDef("一级科目") \'根据型号分组 bd2.Groups.AddDef("二级科目") \'根据型号分组 bd2.Groups.AddDef("三级科目") \'根据型号分组 bd2.Groups.AddDef("四级科目") \'根据型号分组 bd2.Groups.AddDef("五级科目") \'根据型号分组 bd2.Groups.AddDef("六级科目") \'根据型号分组 bd2.Groups.AddDef("七级科目") \'根据型号分组 bd2.Totals.AddDef("支付金额","实际支付_金额") \'对数量进行统计dt2 = bd2.BuildDataSource() dt2 = bd2.BuildDataSource() Dim nms As String() = {"资金来源","预算资金性质","一级科目","二级科目","三级科目","四级科目","五级科目","六级科目","七级科目"} dt1.Combine(nms,dt2,nms) \'将销售统计数据组合到进货统计数据 Tables("窗口1_Table1").DataSource = dt1 \'将统计结果绑定到Table With DataTables("窗口1_Table1").DataCols \'用表达式列计算库存数据 .Add("收支_结余",Gettype(Decimal), "IsNull([预算下达_金额],0) - ISNULL([实际支付_金额],0)") \'.Add("库存_金额",Gettype(Double), "[库存_数量] /[进货_数量] * [进货_金额]") End With
Dim t As Table = Tables("窗口1_Table1") Dim ndr For Each s1 As String In t.DataTable.GetValues("资金来源") For Each s2 As String In t.DataTable.GetValues("预算资金性质", "资金来源 = \'" & s1 & "\'") For Each s3 As String In t.DataTable.GetValues("一级科目", "资金来源 = \'" & s1 & "\' and 预算资金性质 = \'" & s2 & "\'") For Each s4 As String In t.DataTable.GetValues("二级科目", "资金来源 = \'" & s1 & "\' and 预算资金性质 = \'" & s2 & "\' and 一级科目 = \'" & s3 & "\'") For Each s5 As String In t.DataTable.GetValues("三级科目", "资金来源 = \'" & s1 & "\' and 预算资金性质 = \'" & s2 & "\' and 一级科目 = \'" & s3 & "\' and 二级科目 = \'" & s4 & "\'") ndr = t.addnew ndr("资金来源") = s1 ndr("预算资金性质") = s2 ndr("一级科目") = s3 ndr("二级科目") = s4 ndr("三级科目") = s5 ndr("四级科目") = " 小计" Next ndr = t.addnew ndr("资金来源") = s1 ndr("预算资金性质") = s2 ndr("一级科目") = s3 ndr("二级科目") = s4 ndr("三级科目") = "合计" Next ndr = t.addnew ndr("资金来源") = s1 ndr("预算资金性质") = s2 ndr("一级科目") = s3 ndr("二级科目") = "合计" Next ndr = t.addnew ndr("资金来源") = s1 ndr("预算资金性质") = s2 ndr("一级科目") = " 总计" Next Next With Tables("窗口1_Table1") .MergeMode = MergeModeEnum.Standard \'标准合并模式 .MergeCols.Clear() \'清除原来的合并列 .MergeCols.Add("资金来源") \'加入要合并的列 .Cols("资金来源").GrandTotal = True .MergeCols.Add("预算资金性质") \'加入要合并的列 .Cols("预算资金性质").GrandTotal = True .MergeCols.Add("一级科目") \'加入要合并的列 .MergeCols.Add("二级科目") \'加入要合并的列 .MergeCols.Add("三级科目") \'加入要合并的列 .MergeCols.Add("四级科目") \'加入要合并的列 .MergeCols.Add("五级科目") \'加入要合并的列 .MergeSort = "资金来源,预算资金性质,一级科目 desc,二级科目 desc,三级科目 desc,四级科目 desc,五级科目" \'设置合并模式下的排序方式 .AllowMerge = True \'启用合并模式 .GrandTotal = True End With Tables("窗口1_Table1").AutoSizeCols
|