excel导入提速问题
Set xlsBook = xlsApp.Workbooks.Open(FileName) Set xlsSheet = xlsBook.Worksheets(SheetName)
Set rng = xlsSheet.UsedRange
i = rng.Rows.Count
J = rng.Columns.Count
If rst.State = adStateOpen Then rst.Close
rst.Open "SELECT * FROM " & TableName, Conn, adOpenKeyset, adLockOptimistic
M = 6
N = 1
For M = 6 To i
rst.AddNew
For Each Fn In rst.Fields
For N = 1 To J
If xlsSheet.Cells(1, N) = Fn.name Then
rst.Fields(Fn.name) = xlsSheet.Cells(M, N)
Exit For
End If
Next N
Next
rst.Update
Next M
这段代码用来导入EXCEL表并追加到access表的,有点是容错率高,可以根据table字段到sheet里面找相应的字段,忍受不了的缺点是如果字段太多或者行数太多,就非常的慢,有什么解决办法不?我现在手里就有一个5万行120字段的表,导入太慢了,后面的数据量只有越来越大的,有没有什么办法既有这种自动匹配字段功能又能大幅提高速度呢!有的话请给点代码赛,谢谢!
[此贴子已经被作者于2019-10-15 10:34编辑过]