Dim dlg As new OpenFileDialog dlg.Filter = "Excel文件|*.xls" If dlg.ShowDialog = DialogResult.OK Then DataTables("成绩表").DeleteFor("姓名 Is null") Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets("成绩册样表") Tables("成绩表").ResumeRedraw() Tables("成绩表").StopRedraw() Dim nms() As String = {"学校名称","年级","班级","学号","姓名","语文","数学","英语","科学","物理","化学","政治","历史"} For n As Integer = 1 To Sheet.Rows.Count -1 Dim xx As String = sheet(n,0).text Dim nj As String = sheet(n,1).text Dim bj As String = sheet(n,2).Text bj = iif(bj = "", "班级 is null", "班级 = '" & bj & "'") Dim bh As String = val(sheet(n,3).Text) bh = iif(bh = 0, "学号 is null", "学号 = '" & bh & "'") Dim xm As String = sheet(n,4).Text xm = iif(xm = "", "姓名 is null", "姓名 = '" & xm & "'") Dim dr As DataRow = DataTables("成绩表").Find(bh & " And 学校名称 = '" & xx & "' And 年级 = '" & nj & "' And " & bj & " and " & xm) If dr Is Nothing Then '如果不存在同编号的订单 dr = DataTables("成绩表").AddNew() End If For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next Next Tables("成绩表").ResumeRedraw() messagebox.show("111") DataTables("成绩表").save End If
|