Foxtable(狐表)用户栏目专家坐堂 → [求助]对数据表进行计录数交叉统计时,不显示横向汇总


  共有1495人关注过本帖树形打印复制链接

主题:[求助]对数据表进行计录数交叉统计时,不显示横向汇总

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/3 14:00:00 [显示全部帖子]

要单独写代码

 

Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("第一列", Gettype(String), 16)
dtb.AddDef("第二列", Gettype(String), 16)
Dim prds As List(of String) = DataTables("表A").GetValues("第四列", "第四列 is not null")
Dim str As String = ""
Dim cs As String = ""
For Each prd As String In prds
    dtb.AddDef(prd, Gettype(Double))
    str &= "isnull(" & prd & ",0)+"
    cs &= prd & ","
Next
cs &= "合计"
dtb.AddDef("合计", Gettype(Double), str.trim("+"))
dtb.Build()
For Each cus As String() In DataTables("表A").GetValues("第一列|第二列")
    Dim dr As DataRow = DataTables("统计").AddNew()
    dr("第一列") = cus(0)
    dr("第二列") = cus(1)
    For Each prd As String In prds
        dr(prd) = DataTables("表A").Compute("count(第一列)", "第一列 = '" & cus(0) & "' And 第二列 = '" & cus(1) & "' and 第四列 = '" & prd & "'")
    Next
Next

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.TotalOn = cs
g.Caption = "{0} 小计"
t.SubtotalGroups.Add(g)

g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = cs
g.Caption = "总计"
t.SubtotalGroups.Add(g)

t.Subtotal()

MainTable = t


 回到顶部