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(0) Dim dt As DataTable = DataTables("目标表") dt.StopRedraw() Dim pidx As Integer = -1 For n As Integer = 1 To Sheet.Rows.Count -1 If sheet(n, 0).Text > "" Then pidx = n End If Dim fdr As DataRow = dt.find("姓名 = '" & sheet(pidx, 0).Text & "' and 工号 = '" & sheet(pidx,1).text & "'") If fdr Is Nothing Then fdr = dt.AddNew() fdr("姓名") = sheet(pidx, 0).text fdr("工号") = sheet(pidx, 1).Text End If Dim cname As String = sheet(n, 2).Text & "成绩" If dt.datacols.Contains(cname) Then fdr(cname) = sheet(n, 3).Text end if Next dt.ResumeRedraw() End If
|