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 Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets("出库明细") For n As Integer = 1 To Sheet.Rows.Count -1 If sheet(n,5).text > "" Then Dim r As DataRow = t.DataTable.Find("出库单号 = '" & sheet(n, 5).text & "' and 数量 = '" & sheet(n, 6).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 cname > "" AndAlso t.Cols.Contains(cname) Then r(cname) = sheet(n, i).Text End If Next End If Next t.ResumeRedraw() End If