Foxtable(狐表)用户栏目专家坐堂 → [求助]导入Excel 文件如何过滤重复的行【已解决】


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

主题:[求助]导入Excel 文件如何过滤重复的行【已解决】

美女呀,离线,留言给我吧!
18504175995
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:144 积分:1330 威望:0 精华:0 注册:2018/5/10 10:29:00
  发帖心情 Post By:2019/1/16 19:12:00 [显示全部帖子]

请问这段代码要在哪里写入才能发送EXCEL导入指令?

 

Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("表B")
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim r As DataRow = t.DataTable.Find("第一列 = '" & sheet(n, 0).text & "'")
        If r Is Nothing Then r = t.DataTable.AddNew()
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                r(cname) = sheet(n, i).Text
            End If
        Next
    Next
    t.ResumeRedraw()
End If


 回到顶部