Foxtable(狐表)用户栏目专家坐堂 → 如何编码实现数据有条件合并


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

主题:如何编码实现数据有条件合并

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/3/6 16:35:00 [显示全部帖子]

Dim dlg As new OpenFileDialog
dlg.Filter = "Excel|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
    Dim t As Table = Tables("表A")
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    t.StopRedraw()
    Dim nms() As String = {"姓名","身份证号","婚姻状况","文化程度","调入日期"}
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim bh As String = sheet(n,1).Text
        If bh > "" Then
            Dim dr As DataRow = t.DataTable.Find("身份证号 = '" & bh & "'")
            If dr Is Nothing Then '如果不存在同编号的订单
                dr = t.DataTable.AddNew()
            End If
            For m As Integer = 0 To nms.Length - 1
                dr(nms(m)) = Sheet(n,m).Value
            Next
        End If
    Next
    t.ResumeRedraw()
End If

 回到顶部