Foxtable(狐表)用户栏目专家坐堂 → [求助]合并(导入)去重的问题


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

主题:[求助]合并(导入)去重的问题

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


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

Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("勤务信息表")
    t.ResumeRedraw()
    t.StopRedraw()
    Dim App As New MSExcel.Application
    try
        Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName)
        Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
        Dim Rg As MSExcel.Range = Ws.UsedRange
        Dim arg = rg.value
        For n As Integer = 2 To rg.Rows.Count
            Dim r As DataRow = t.DataTable.Find("日期 = #" & arg(n, 1) & "# and 航班号 = '" & arg(n, 3) & "' and 安全员 = '" & arg(n, 11) & "'")
           
            If r Is Nothing Then r = t.DataTable.AddNew()
            For i As Integer = 1 To rg.Columns.count
                Dim cname As String = arg(1,i)
                If cname > "" AndAlso t.Cols.Contains(cname) Then
                    If t.Cols(cname).IsDate AndAlso arg(n,i).Gettype.name = "double" Then
                        r(cname) = DateTime.FromOADate(arg(n,i))
                    Else
                        r(cname) = arg(n, i)
                    End If
                End If
            Next
        Next
    catch ex As exception
        msgbox(ex.message)
        MessageBox.Show("导入失败!","恭喜!")
    finally
        t.ResumeRedraw()
        app.quit
    End try
   
End If

 回到顶部