Foxtable(狐表)用户栏目专家坐堂 → [求助]求一段行转列的代码,急需啊!


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

主题:[求助]求一段行转列的代码,急需啊!

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/4/7 17:28:00 [显示全部帖子]

代码

 

For i As Integer = Tables("金工总表").TopPosition To Tables("金工总表").BottomPosition
    Dim adr As Row  = Tables("金工总表").Rows(i)
    If adr.IsNull("路线卡代号") = False Then
        For Each adc As DataCol In DataTables("金工总表").DataCols
            If adc.Name.StartsWith("工序") AndAlso adr.IsNull(adc.Name) = False Then
                Dim bdr As DataRow = DataTables("路线卡明细").AddNew()
                bdr("序号") = adr("序号")
                bdr("订单号") = adr("订单号")
                bdr("路线卡代号") = adr("路线卡代号")
                bdr("工序") = adr(adc.Name)
            End If
        Next
    End If
Next
DataTables("路线卡明细").Save()
MainTable = Tables("路线卡明细")


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/4/11 10:20:00 [显示全部帖子]

 是不是这个意思?

 

For i As Integer = Tables("金工总表").TopPosition To Tables("金工总表").BottomPosition
    Dim adr As Row  = Tables("金工总表").Rows(i)
    If adr.IsNull("路线卡代号") = False Then
        Dim fdr As DataRow = DataTables("路线卡明细").Find("路线卡代号 = '" & adr("路线卡代号") & "'")
        If fdr Is Nothing Then
            For Each adc As DataCol In DataTables("金工总表").DataCols
                If adc.Name.StartsWith("工序") AndAlso adr.IsNull(adc.Name) = False Then
                    Dim bdr As DataRow = DataTables("路线卡明细").AddNew()
                    bdr("序号") = adr("序号")
                    bdr("订单号") = adr("订单号")
                    bdr("路线卡代号") = adr("路线卡代号")
                    bdr("工序") = adr(adc.Name)
                End If
            End If
        Next
    End If
Next
DataTables("路线卡明细").Save()
MainTable = Tables("路线卡明细")


 回到顶部