#include <Excel.au3>
#include <Array.au3>
$sFileExcel = 'C:\STORAGE\RTSI.xlsx';
Local $oExcel = _ExcelBookAttach($sFileExcel,'FilePath');
;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
; We can fill-up some cells using a simple loop and random Numbers
;For $y = 1 To 100 ;Start on Column 1
; For $x = 1 To 100
; _ExcelWriteCell($oExcel, Round(Random(1000, 10000), 0), $x, $y) ;Some random numbers to file
; Next
;Next
local $iTimer=TimerInit()
$aArray = _ExcelReadSheetToArrayQuick($oExcel) ;Using Default Parameters
ConsoleWrite("_ExcelReadSheetToArrayQuick: "&Timerdiff($iTimer) & @LF)
_ArrayDisplay($aArray, "Array using Default Parameters")
local $iTimer=TimerInit()
$aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
ConsoleWrite("_ExcelReadSheetToArray: "&Timerdiff($iTimer) & @LF)
_ArrayDisplay($aArray, "Array using Default Parameters")
Func _ExcelReadSheetToArrayQuick($oExcel, $iStartRow = 1, $iStartColumn = 1, $iRowCnt = 0, $iColCnt = 0)
Local $avRET[1][2] = [[0, 0]] ; 2D return array
; Test inputs
If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
If $iStartRow < 1 Then Return SetError(2, 0, 0)
If $iStartColumn < 1 Then Return SetError(2, 1, 0)
If $iRowCnt < 0 Then Return SetError(3, 0, 0)
If $iColCnt < 0 Then Return SetError(3, 1, 0)
; Get size of current sheet as R1C1 string
; Note: $xlCellTypeLastCell and $x1R1C1 are constants declared in ExcelCOM_UDF.au3
Local $sLastCell = $oExcel.Application.Selection.SpecialCells($xlCellTypeLastCell).Address(True, True, $xlR1C1)
; Extract integer last row and col
$sLastCell = StringRegExp($sLastCell, "\A[^0-9]*(\d+)[^0-9]*(\d+)\Z", 3)
Local $iLastRow = $sLastCell[0]
Local $iLastColumn = $sLastCell[1]
; Return 0's if the sheet is blank
If $sLastCell = "R1C1" And $oExcel.Activesheet.Cells($iLastRow, $iLastColumn).Value = "" Then Return $avRET
; Check input range is in bounds
If $iStartRow > $iLastRow Then Return SetError(2, 0, 0)
If $iStartColumn > $iLastColumn Then Return SetError(2, 1, 0)
If $iStartRow + $iRowCnt - 1 > $iLastRow Then Return SetError(3, 0, 0)
If $iStartColumn + $iColCnt - 1 > $iLastColumn Then Return SetError(3, 1, 0)
; Check for defaulted counts
If $iRowCnt = 0 Then $iRowCnt = $iLastRow - $iStartRow + 1
If $iColCnt = 0 Then $iColCnt = $iLastColumn - $iStartColumn + 1
; Size the return array
ReDim $avRET[$iRowCnt][$iColCnt]
;$avRET[0][0] = $iRowCnt
;$avRET[0][1] = $iColCnt
$avRET = $oExcel.Application.WorksheetFunction.Transpose($oExcel.Activesheet.Cells($iStartRow, $iStartColumn).Resize($iRowCnt, $iColCnt).Value) ; здесь происходит считывание целым массивом, а не по элементно
;Return data
Return $avRET
EndFunc ;==>_ExcelReadSheetFromArrayQuick