以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]单元格调整2,内祥! (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=104329) |
-- 作者:ymjr2011 -- 发布时间:2017/7/27 14:32:00 -- [求助]单元格调整2,内祥! 内祥! |
-- 作者:有点甜 -- 发布时间:2017/7/27 15:20:00 -- For Each r As Row In Tables("表A").Rows For Each c As Col In r.Table.Cols If r.IsNull(c.name) = False Then Dim n As Integer = -1 For i As Integer = c.Index-1 To 0 Step -1 If i = 0 AndAlso r.Isnull(i) Then n = 0 ElseIf r.IsNull(i) = False Then n = i+1 Exit For End If Next If n > -1 Then Dim fdr As DataRow = DataTables("表B").find("行 = \'" & r.index+1 & "\' and 列 = \'" & c.name & "\'") If fdr Is Nothing Then fdr = DataTables("表B").addnew fdr("行") = r.Index+1 End If fdr("列") = r.Table.Cols(n).name r(n) = r(c.name) r(c.name) = Nothing End If End If Next Next |
-- 作者:ymjr2011 -- 发布时间:2017/7/27 15:35:00 -- 放在计划管理里面,过一下表A就只留下a和d了,其他数据没了 |
-- 作者:ymjr2011 -- 发布时间:2017/7/27 16:14:00 -- 正常结果如下图: [此贴子已经被作者于2017/7/27 16:15:10编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/7/27 17:01:00 -- For Each r As Row In Tables("表A").Rows For Each c As Col In r.Table.Cols If r.IsNull(c.name) = False Then Dim n As Integer = -1 For i As Integer = c.Index-1 To 0 Step -1 If i = 0 AndAlso r.Isnull(i) Then n = 0 ElseIf r.IsNull(i) = False Then If r.Isnull(i+1) Then n = i+1 End If Exit For End If Next If n > -1 Then Dim fdr As DataRow = DataTables("表B").find("行 = \'" & r.index+1 & "\' and 列 = \'" & c.name & "\'") If fdr Is Nothing Then fdr = DataTables("表B").addnew fdr("行") = r.Index+1 End If fdr("列") = r.Table.Cols(n).name r(n) = r(c.name) r(c.name) = Nothing End If End If Next Next |