参考
Dim t As Table = Tables("学生基本信息") 'e.Form.controls("Table1").Table
Dim r As DataRow
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
t.StopRedraw()
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim newcount As Integer = 0
Dim oldcount As Integer = 0
For n As Integer = 1 To Sheet.Rows.Count -1
r = t.DataTable.SQLFind("身份证号 = '" & sheet(n, 2).text & "'")
If r Is Nothing Then
r = t.DataTable.AddNew()
Dim max As String = DataTables("学生基本信息").SQLCompute("Max(学生编号)","学生编号 Like '201809%'")
If max = "" Then
r("学生编号") = "201809" & "001"
Else
Dim v As Integer = max.SubString(6,3)
r("学生编号") = "201809" & format(v +1,"000")
End If
newcount += 1
r("编号") = "1"
Else
r("编号") = "2"
oldcount += 1
End If
For i As Integer = 0 To sheet.Cols.Count -1
Dim cname As String = sheet(0, i).text
If t.Cols.Contains(cname) Then
r(cname) = sheet(n, i).Text
End If
Next
r.save
Next
msgbox("新增" & newcount & " " & "更新旧数据" & oldcount)
t.ResumeRedraw()
End If
t.SetColVisibleWidth("学生编号|90|学生姓名|120|身份证号|120|民族|60|编号|40|")
t.DataTable.load
t.Filter = "编号 = '1' Or 编号 = '2'"