以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]垂直列与水平行的转换问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=103886) |
-- 作者:qingqian369 -- 发布时间:2017/7/19 10:37:00 -- [求助]垂直列与水平行的转换问题 问一个垂直列变水平行的问题 原表是这样的 写了如下代码后, Dim dtb As New DataTableBuilder("表B") dtb.AddDef("第一列",Gettype(String), 4) dtb.AddDef("第二列",Gettype(String), 10) dtb.AddDef("第三列_名称",Gettype(String), 10) dtb.AddDef("第三列_内容",Gettype(String), 10) dtb.AddDef("列b",Gettype(String), 10) dtb.AddDef("列c",Gettype(String), 4) dtb.AddDef("第六列",Gettype(String), 10) dtb.Build() Dim kms() As String = {"第三列_a","第四列_a","第五列_a"} For Each dr1 As DataRow In DataTables("实验").DataRows For Each km As String In kms Dim dr2 As DataRow = DataTables("表B").AddNew() dr2("第一列") = dr1("第一列") dr2("第二列") = dr1("第二列") dr2("第六列") = dr1("第六列") dr2("列b") = dr1("第二列") dr2("列c") = dr1("第六列") dr2("第三列_名称") = km dr2("第三列_内容") = dr1(km) Next Next MainTable = Tables("表B") 变成了这样 我想问,列b和列c要怎么样定义,他们下面的内容才是和a相吻合的内容啊? 谢谢大大
|
-- 作者:有点蓝 -- 发布时间:2017/7/19 11:13:00 -- Dim dtb As New DataTableBuilder("表D") dtb.AddDef("第一列",Gettype(String), 4) dtb.AddDef("第二列",Gettype(String), 10) dtb.AddDef("列a_名称",Gettype(String), 10) dtb.AddDef("列a_内容",Gettype(String), 10) dtb.AddDef("列b_名称",Gettype(String), 10) dtb.AddDef("列b_内容",Gettype(String), 10) dtb.AddDef("列c_名称",Gettype(String), 10) dtb.AddDef("列c_内容",Gettype(String), 10) dtb.Build() Dim kms() As String = {"第三列_a","第四列_a","第五列_a"} Dim kms2() As String = {"第三列_b","第四列_b","第五列_b"} Dim kms3() As String = {"第三列_c","第四列_c","第五列_c"} For Each dr1 As DataRow In DataTables("表C").DataRows For i As Integer = 0 To kms.Length - 1 Dim dr2 As DataRow = DataTables("表D").AddNew() dr2("第一列") = dr1("第一列") dr2("第二列") = dr1("第二列") \'dr2("第六列") = dr1("第六列") dr2("列a_名称") = kms(i) dr2("列a_内容") = dr1(kms(i)) dr2("列b_名称") = kms2(i) dr2("列b_内容") = dr1(kms2(i)) dr2("列c_名称") = kms3(i) dr2("列c_内容") = dr1(kms3(i)) Next Next MainTable = Tables("表D")
|
-- 作者:qingqian369 -- 发布时间:2017/7/19 12:26:00 -- [求助] 谢谢大大,已用 |