红袍老师,这段代码导入时,会把表中已有的记录也导入进去,我想导入时自动过滤掉表中已有的记录,只导入新增的记录,你看怎么修改呢?
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