连接成功的时间,与不成功的时间。相差3秒。如果10万行的2007,连接成功要19秒。
Dim st As Date = Date.Now
Dim dlg As new OpenFileDialog
dlg.Filter = "Excel文件|*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
If Connections.TryConnect("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dlg.FileName & ";Extended Properties='Excel 12.0 xml;HDR=yes'") = True
'msgbox("OK")
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒") 19秒
Else
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒") 1.5秒
MessageBox.Show("不成功")
End If
End If
Dim st1 As Date = Date.Now
Connections.Add("test","Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dlg.FileName & ";Extended Properties='Excel12.0 xml;HDR=yes'"") ‘----20秒----
MessageBox.Show("耗时: " & (Date.Now - st1).TotalSeconds & "秒")
什么玩意?