Что нового

Импорт масива из EXSEL

gezan1

Новичок
Сообщения
47
Репутация
0
Добрый день.
Значение из ячейки в другую программу
Код:
Local $aResult0 = _Excel_RangeRead($oWorkbook, Default, "A1")
; Запуск нужной проги
Sleep(500)
$hWnd1 = WinWait("[CLASS:TFMain]", "", 10)
If Not $hWnd1 Then
    MsgBox(4096, 'Сообщение', 'Окно не найдено, завершаем работу скрипта')
    Exit
EndIf
ControlSend($hWnd1,'' , "[CLASS:TInplaceEdit; INSTANCE:2]",$aResult0)
 Send("+{F5}")

А как вставить массив??
Код:
Local $aResult002 = _Excel_RangeRead($oWorkbook, 1, "A1:C3", 1)
_ArrayDisplay($aResult002, "Excel UDF: _Excel_" ); так все выводит
; ?????
; Запуск нужной проги
Sleep(500)
$hWnd1 = WinWait("[CLASS:TFMain]", "", 10)
If Not $hWnd1 Then
    MsgBox(4096, 'Сообщение', 'Окно не найдено, завершаем работу скрипта')
    Exit
EndIf
ControlSend($hWnd1,'' , "[CLASS:TInplaceEdit; INSTANCE:2]",$aResult002)
 Send("+{F5}")
 

alex33

Скриптер
Сообщения
1,457
Репутация
186
Код:
Local $aResult = _Excel_RangeRead($oWorkbook, Default, "A1:C10")
 
Автор
G

gezan1

Новичок
Сообщения
47
Репутация
0
Так я пробовал сначала, тоже показывает
Код:
_ArrayDisplay

Но в прогу не передает.
 

vovsla

Осваивающий
Сообщения
607
Репутация
36
Куда нужно передавать?

Вот эта функция читает быстрее
Код:
;~ -----------------------------------------------------------------------------_ExcelReadSheetToArrayQuick----------------------------------------------------------------------------
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)
    Local $sLastCell = $oExcel.Activesheet.Cells.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
 
Верх