Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls" dlg.MultiSelect = False '不允许选择多个文件 If dlg.ShowDialog =DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim nms() As String = {"姓名","身份证号码","单位","培训日期","培训类型","培训项目"} Dim idds(Sheet.Cols.count-1) As String For n As Integer = 0 To Sheet.Cols.Count -1 idds(n) = Sheet(0,n).Value Next Dim iscontains = True For Each nm As String In nms Output.Show(nm) If array.indexof(idds, nm) < 0 Then msgbox(nm) iscontains = False Exit For End If Next If iscontains = False Then messagebox.show("所选文件部分必选字段缺少,无法导入!") Return "所选文件部分必选字段缺少,无法导入!" End If End If
|