Foxtable(狐表)用户栏目专家坐堂 → 多值字段统计


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

主题:多值字段统计

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


加好友 发短信
等级:狐神 帖子:4752 积分:34568 威望:0 精华:0 注册:2008/8/31 22:44:00
  发帖心情 Post By:2015/6/6 16:49:00 [显示全部帖子]

试试以下代码:
表1
Dim g As New CrossTableBuilder("统计表", DataTables("表B"))
g.HGroups.AddDef("缺陷等级")
g.VGroups.AddDef("月")
g.Totals.AddDef("月", AggregateEnum.Count)
g.HorizontalTotal = True
g.Build()
Tables("统计表").AutoSizeCols
MainTable = Tables("统计表")

表2
Dim dtb As New DataTableBuilder("中间表")
dtb.AddDef("缺陷原因", Gettype(String), 32)
dtb.AddDef("月", Gettype(String), 32)
dtb.TableVisible = False
dtb.Build()
For Each dr As DataRow In DataTables("表B").DataRows
    For Each s As String In dr("缺陷原因").split(",")
        Dim dr1 As DataRow = DataTables("中间表").AddNew
        dr1("缺陷原因") = s
        dr1("月") = dr("月")
    Next
Next

Dim b As New CrossTableBuilder("统计表",DataTables("中间表"))
b.HGroups.AddDef("缺陷原因")
b.VGroups.AddDef("月")
b.Totals.AddDef("月",AggregateEnum.Count)
b.HorizontalTotal = True
b.Build
Tables("统计表").AutoSizeCols
MainTable = Tables("统计表")

表3
Dim dtb As New DataTableBuilder("中间表")
dtb.AddDef("责任人", Gettype(String), 32)
dtb.AddDef("缺陷原因", Gettype(String), 32)
dtb.AddDef("月", Gettype(String), 32)
dtb.TableVisible = False
dtb.Build()
For Each dr As DataRow In DataTables("表B").DataRows
    For Each s As String In dr("缺陷原因").split(",")
        Dim dr1 As DataRow = DataTables("中间表").AddNew
        dr1("责任人") = dr("责任人")
        dr1("缺陷原因") = s
        dr1("月") = dr("月")
    Next
Next

Dim b As New CrossTableBuilder("统计表",DataTables("中间表"))
b.HGroups.AddDef("责任人")
b.HGroups.AddDef("缺陷原因")
b.VGroups.AddDef("月")
b.Totals.AddDef("月",AggregateEnum.Count)
b.HorizontalTotal = True
b.Build
Tables("统计表").AutoSizeCols
MainTable = Tables("统计表")

 回到顶部