Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog =DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) For Each sheet As xls.sheet In book.sheets If DataTables.Contains(sheet.name)=True Then Dim t As Table = Tables(sheet.name) t.ResumeRedraw() t.StopRedraw() For n As Integer =2 To Sheet.Rows.Count -4 Dim cnames As String="1=1" For i As Integer = 0 To sheet.Cols.Count -1 cnames &= " and " & sheet(1, i).text.replace("/", "") & "=" & "'" & Sheet(n,i).text & "'" Next MessageBox.Show(cnames) Dim drs As DataRow=DataTables(sheet.name).Find(cnames) MessageBox.Show(1) If drs Is Nothing Then Dim r As DataRow= t.DataTable.AddNew() For i As Integer = 0 To sheet.Cols.Count -1 Dim cname As String = sheet(1, i).text.replace("/", "") If cname > "" AndAlso t.Cols.Contains(cname) Then r(cname)= sheet(n, i).Text End If Next End If Next t.ResumeRedraw() End If Next End If
|