Dim js1 As Integer = Tables("学生信息表").Rows.Count
Forms("主界面").Open()
MainTable = Tables("主界面")
Dim dlg As new OpenFileDialog
dlg.Filter= "Excel文件|*.xls"
If dlg.ShowDialog = DialogResult.Ok Then
application.DoEvents
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
StatusBar.Message1= "正在统计"
StatusBar.ProgressBar.Maximum = sheet.Rows.Count
StatusBar.ProgressBar.Minimum = 0
StatusBar.ProgressBar.Visible =True
application.DoEvents
If sheet(0,0).text <> "序号" Or sheet(0,1).text <> "学校代码" Or sheet(0,2).text <> "学校名称" Or sheet(0,3).text <> "班代码" Then
MessageBox.Show("您的数据源不符合国家开放大学报表平台的数据格式,不能导入学生信息表数据!", "提示")
Else
DataTables("学生信息表").StopRedraw
DataTables("学生信息表").DataCols("照片").DefaultFolder = ProjectPath & "\证件照片"
For i As Integer = 1 To sheet.Rows.Count -1
Dim dr As DataRow = DataTables("学生信息表").find("学号 = '" & sheet(i,0).text & "'")
If dr IsNot Nothing Then
dr("学籍状态") = sheet(i,9).text
Else
dr = DataTables("学生信息表").AddNew()
dr("序号") = sheet(i,0).text
dr("学校代码") = sheet(i,1).text
dr("学校名称") = sheet(i,2).text
dr("班代码") = sheet(i,3).text
dr("班名称") = sheet(i,4).text
dr("姓名") = sheet(i,5).text
dr("学号") = sheet(i,6).text
dr("性别") = sheet(i,7).text
dr("学籍状态") = sheet(i,8).text
dr("出生年月") = sheet(i,9).text
dr("学生类型代码") = sheet(i,10).text
dr("学生类型") = sheet(i,11).text
dr("民族") = sheet(i,12).text
dr("身份证号") = sheet(i,13).text
dr("专业代码") = sheet(i,14).text
dr("专业名称") = sheet(i,15).text
dr("入学年度") = sheet(i,16).text
dr("学期") = sheet(i,17).text
dr("规则号") = sheet(i,18).text
dr("入学前专业所属学科门类代码") = sheet(i,19).text
dr("原毕业时间") = sheet(i,20).text
dr("毕业学校") = sheet(i,21).text
dr("原专业名称") = sheet(i,22).text
dr("文化程序") = sheet(i,23).text
End If
dr("照片") = dr("身份证号") & ".jpg"
If FileSys.FileExists(DataTables("学生信息表").DataCols("照片").DefaultFolder & "\" & dr("照片")) = True Then
dr("是否有照片") = True
End If
Dim s As String = dr("班名称")
If s.Contains("4200311") Then
dr("班名称中文") = s.SubString(0,s.Length - 15)
Else
dr("班名称中文") = dr("班名称")
End If
StatusBar.ProgressBar.Value = i
StatusBar.Message2= Math.Ceiling(i/sheet.Rows.Count * 100) & "%"
application.DoEvents
Next
DataTables("学生信息表").ResumeRedraw
End If
End If
'DataTables("学生信息表").DeleteFor("身份证号 is null or 身份证号 = '身份证'")
Dim js2 As Integer = Tables("学生信息表").Rows.Count
Dim js3 As Integer = js2 - js1
MessageBox.Show("祝贺你!本次共成功导入" & js3 & "人!")
MainTable = Tables("学生信息表")