以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 关于导入代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=85901) |
-- 作者:scofields -- 发布时间:2016/6/5 10:47:00 -- 关于导入代码 红袍老师,这段代码导入时,会把表中已有的记录也导入进去,我想导入时自动过滤掉表中已有的记录,只导入新增的记录,你看怎么修改呢? Dim dlg As New OpenFileDialog dlg.Filter= "Excel文件|*.xls" If dlg.ShowDialog = DialogResult.Ok Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets("船运计划2") Tables("船运计划2").StopRedraw() For i As Integer = 1 To Sheet.Rows.Count -1 Dim dr2 As DataRow = DataTables("船运计划2").Find("客户名 = \'" & sheet(i,1).Text & "\'") If dr2 Is Nothing Then Dim r As Row = Tables("船运计划2").AddNew() For Each m As Col In Tables("船运计划2").Cols r(m.name) = Sheet(i,m.Index).Value Next End If Next Tables("船运计划2").ResumeRedraw() Tables("船运计划2").DataTable.Save() End If
|
-- 作者:大红袍 -- 发布时间:2016/6/5 13:05:00 -- 弹出这个值,你这个值,肯定不是 【用户名】
msgbox(sheet(i,1).Text) |