Dim dlg As new OpenFileDialog dlg.Filter = "Excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then Dim t As Table = Tables("表A") Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) t.StopRedraw() Dim nms() As String = {"姓名","身份证号","婚姻状况","文化程度","调入日期"} For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,1).Text If bh > "" Then Dim dr As DataRow = t.DataTable.Find("身份证号 = '" & bh & "'") If dr Is Nothing Then '如果不存在同编号的订单 dr = t.DataTable.AddNew() End If For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next End If Next t.ResumeRedraw() End If
|