Dim dlg As New OpenFileDialog dlg.MultiSelect = True dlg.Filter= "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then For Each fl As String In dlg.FileNames Dim Book As New xls.Book(fl) Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim nms As new Dictionary (of String,Integer) For i As Integer = 0 To Sheet.Cols.Count -1 If Sheet(0,i).Value <> "" Then nms.add(Sheet(0,i).Value,i) End If Next For n As Integer = 1 To Sheet.Rows.Count -1 Dim bj2 As String = sheet(n,nms("班级")).Text '班级 For Each km As String In nms.Keys Dim dr As DataRow dr = DataTables("分数段统计").Find("班级 = '" & bj2 & "' and 科目 = '" & km & "'") If dr IsNot Nothing dr("班科任") = sheet(n,nms(km)).text End If Next Next Next End If
|