我也来一个,用ADO方式读取 与 Excel Open方式 读取比较,哈哈,献丑了。相比之下,ADO虽有缺点,但速度要稍快一些#include <Excel.au3>
#include <Array.au3>
$begin = TimerInit()
Dim $Cn1 = ObjCreate("Adodb.Connection")
Dim $Rs1 = ObjCreate("Adodb.Recordset")
With $Cn1
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties") = "Excel 8.0;HDR=No;IMEX=1"
.Properties("Data Source") = @ScriptDir & "\1.xls"
.CursorLocation = 3 ;//adUseClient = 3
.Open
EndWith
dim $arr
$Rs1 = $Cn1.ExeCute("SELECT * FROM WHERE LEN(F1)>0")
if not ($rs1.EOF AND $rs1.BOF) Then
$arr = $rs1.GetRows()
Endif
$rs1.close
$cn1.close
$dif = StringFormat("ado读取耗费时间[%.4f]秒,读取记录[%u]条",TimerDiff($begin)/1000, ubound($arr) )
_ArrayDisplay($arr, $dif )
#include <Excel.au3>
#include <Array.au3>
DIM$eExcelArray
$begin =TimerInit()
$eExcel = _ExcelBookOpen(@ScriptDir&"\1.XLS",0,True) ;打開EXCEL表
With $eExcel.ActiveSheet ;Worksheets("")如果要用工作表名稱 就改成這邊
$eExcelArray= .range("a1").currentregion.value ;第一行讀取
$eExcelArray= .application.transpose($eExcelArray) ;行列互換
;.parent.close(false) ;讀取完畢後 把頁面關掉的
EndWith
_ExcelBookClose($eExcel, 0, 0)
$eExcel=0
$dif = StringFormat("ExcelOpen耗费时间[%.4f]秒,读取记录[%u]条",TimerDiff($begin)/1000, ubound($eExcelArray) )
_ArrayDisplay($eExcelArray, $dif )
{:face (327):}
页:
1
[2]