Sign in to follow this  
Followers 0
apoliemans

rows and colums transposed after pasting array into Excel

3 posts in this topic

See below script based on example _ExcelWriteSheetFromArray.au3.

If I do the same in COM (see bottom lines added by me) , a transpose of the array seems to be required to get the same result. Can someone explain?

Local $oExcel = _ExcelBookNew()

;Declare the Array
Local $aArray[5][2] = [["LocoDarwin", 1],["Jon", 2],["big_daddy", 3],["DaleHolm", 4],["GaryFrost", 5]] ;0-Base Array

;Paste array into sheet1
$oExcel.ActiveWorkBook.Sheets(1).Activate
_ExcelWriteSheetFromArray($oExcel, $aArray, 1, 1, 0, 0)

;Paste same array into sheet2 gives unexpected result
$oExcel.ActiveWorkBook.Sheets(2).Activate
$oExcel.Activesheet.Cells(1,1).Resize(5,2) = $aArray

;Only after transposing first the array is pasted properly
;$oExcel.Activesheet.Cells(1,1).Resize(5,2) = $oExcel.WorksheetFunction.Transpose($aArray)

Share this post


Link to post
Share on other sites



Excel deals with column names as the predominant dimension.  Notice that whenever you reference a cell in a formula it is "A1", "C6", "CN28", etc.

Share this post


Link to post
Share on other sites

@LeppyR64, now it makes sense, thanks for explaining.
Andre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0