Foxtable(狐表)用户栏目专家坐堂 → 表的转换


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

主题:表的转换

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


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2010/11/20 20:13:00 [显示全部帖子]

'''
Dim dtb As New DataTableBuilder("Excel转置")
dtb.AddDef("型号", Gettype(String),15)
dtb.AddDef("规格", Gettype(String),15)
dtb.AddDef("材料", Gettype(String))
dtb.AddDef("用量", Gettype(Double))
dtb.Build()
MainTable= Tables("Excel转置")
For i As Integer = 0 To Tables("EXCEL表").count -1
    If Tables("EXCEL表").rows(i)("型号") > ""   '用IsNull好些
        For ii As Integer = 2 To Tables("EXCEL表").cols.count -1
            Dim lm As String = Tables("EXCEL表").cols(ii).name
            If Tables("EXCEL表").rows(i).IsNull(lm) = False
                Tables("EXCEL转置").addnew
                Dim r As Row = Tables("EXCEL转置").current
                r("型号") = Tables("EXCEL表").rows(i)("型号")
                r("规格") = Tables("EXCEL表").rows(i)("规格")
                r("材料") = lm
                r("用量") = Tables("EXCEL表").rows(i)(lm)
            End If
        Next
    End If
Next

 回到顶部