Clark Posted September 9, 2011 Posted September 9, 2011 Hi there I can't find out how to do this in the help. I read into an array via some SQL. I then want to output the array into Excel using _ExcelWriteArray. _ExcelWriteArray can only write a 1d Array to I am assuming I would need to send it a row of the 2d array at a time. This is what I have, that fails, as it does not like the way I reference the array variable. $iRval= _Sql_GetTable2D($hDBHandle,$sSQL,$outArray,$iRows,$iColumns) if $iRval <> $SQL_OK then Msgbox(0 + 16 +262144,"Error","Unable to execute query") Exit EndIf _ArrayDisplay($outArray) ; This displays the array just fine for $i = 1 to uBound($outArray) ExcelPrint($outArray[$i]) ; Autoit does not like the $i next This fails on the ExcelPrint line, which calls a function that contains _ExcelWriteArray. I'm not sure where to go from here.
AdmiralAlkex Posted September 9, 2011 Posted September 9, 2011 I can't find out how to do this in the help.That's because there is no way to do that. Either address a single item (array[x][y]) or the whole thing ($array). Create a secondary/temporary loop using a For-loop and UBound(), or use a way to write to Excel without arrays. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
PsaltyDS Posted September 11, 2011 Posted September 11, 2011 You can use _ExcelWriteSheetFromArray() to write 2D array data. Or do it directly: Global $aArray[3][3] = [["A1", "B1", "C1"], ["A2", "B2", "C2"], ["A3", "B3", "C3"]] $oExcel.Activesheet.Range("A1:C3").Value = $aArray Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Clark Posted September 12, 2011 Author Posted September 12, 2011 Thankyou. _ExcelWriteSheetFromArray() will work nicely for me.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now