Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls"
dlg.MultiSelect = True '允许选择多个文件
If dlg.ShowDialog =DialogResult.OK Then
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("学生信息表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"国籍号","学号","班级","班级编号","姓名","性别","出生年月","民族","政治面貌","籍贯","身份证号","户口所在地","毕业学校","兴趣爱好","所获荣誉","家庭住址"}
For n As Integer = 2 To Sheet.Rows.Count -1
Dim bh As String = sheet(n,1).Text
If DataTables("学生信息表").Find("学号 = '" & bh & "' and 学校 = '" & e.form.Controls("xxmc").text & "' ") Is Nothing Then '如果不存在同编号的订单
Dim r As Row = Tables("学生信息表").AddNew()
'Dim r As Row = Tables("班主任主页_Table1").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n,m).Value
Next
'Else
' MessageBox.Show("该学生已存在!请检查数据!")
End If
Next
Tables("学生信息表").ResumeRedraw()
End If
For Each dr As DataRow In DataTables("学生信息表").DataRows
If dr("学号") IsNot Nothing Then
dr("班级编号") = dr("学号").SubString(0,6)
dr("入学年份") = dr("学号").SubString(0,4)
dr("学校") = "" & e.Form.Controls("xxmc").text & ""
End If
Next
Tables("学生信息表").save