本帖最后由 blue_dvd 于 2012-11-17 08:04 编辑
测试过用_ExcelReadCell($oExcel, 行,列)时读取Excel表格的速度好慢,我计算过了,大概36行*10列的表格用了15秒,有没有更快的读取Excel表格的过程或函数?或是在读取过程中,有个图标或文字说明正在读取中!具体给个例子,谢谢!
花了几个小时搜论坛找到一位高手的解答Func _ExcelReadToArrayFast($oExcel, $firstRow=1, $firstCol=1, $lastRow=0, $lastCol=0, $vSheet="")
$usedRange = _ExcelSheetUsedRangeGet($oExcel, $vSheet)
If IsArray($usedRange) Then
If $lastCol = 0 Then $lastCol = $usedRange[2]
If $lastRow = 0 Then $lastRow = $usedRange[3]
Else
Return 0
EndIf
Dim $aFixedArray[$lastRow - $firstRow + 2][$lastCol - $firstCol + 2]
ProgressOn("读取进度", "努力读取中...")
For $i = $firstRow To $lastRow
ProgressSet($i/($lastRow/100), "读取第"&$i&"行 / 总行数"&$lastRow - $firstRow)
$aTempArray = $oExcel.Activesheet.Range($oExcel.Cells($i, $firstCol), $oExcel.Cells($i, $lastCol)).Value
$b = $i - $firstRow + 1
For $a = 0 To ($lastCol - $firstCol)
$c = $a + 1
$aFixedArray[$b][$c] = $aTempArray[$a][0]
Next
Next
ProgressOff()
Return $aFixedArray
EndFunc ;==>_ExcelReadToArrayFast
读的速度快很多! |