Jump to content

rows and colums transposed after pasting array into Excel


 Share

Go to solution Solved by LeppyR64,

Recommended Posts

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...