Foxtable(狐表)用户栏目专家坐堂 → [求助]水平表和垂直表转换


  共有2868人关注过本帖平板打印复制链接

主题:[求助]水平表和垂直表转换

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110334 积分:561518 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/11/6 11:11:00 [只看该作者]

Dim dtb As New DataTableBuilder("表B")
dtb.AddDef("学期", Gettype(String), 32)
dtb.AddDef("科目", Gettype(String), 32)
For Each v As String In DataTables("表A").GetValues("姓名")
    dtb.AddDef(v, Gettype(Double))
Next
dtb.Build()
For Each v As String In DataTables("表A").GetValues("学期")
    For Each dc As DataCol In DataTables("表A").datacols
        If dc.name <> "学期" AndAlso dc.name <> "姓名"
            Dim dr1 As DataRow = DataTables("表B").AddNew()
            dr1("学期") = v
            dr1("科目") = dc.name
            For Each v2() As String In DataTables("表A").GetValues("姓名|" & dc.name)
                dr1(v2(0)) = v2(1)
            Next
        End If
    Next
Next
MainTable = Tables("表B")

 回到顶部