Jump to content
Sign in to follow this  
SlapshotBoston

Get an array from excel and loop through for input into another application.....?

Recommended Posts

SlapshotBoston

So, I am looking to grab an arrary from an excel spreadsheet which I have been able to do using:

#include <Excel.au3>
#include <Array.au3>

Local $excelDoc = "C:WorkSheet.xlsx"


$oExcel = _ExcelBookOpen($excelDoc)
_ExcelSheetActivate($oExcel,"Sheet2")
Local $array=_ExcelReadArray($oExcel, 1,1,3,1,1)

So now I have this array ($array) but I dont know how to get the data back out of it to write into the fields in a web application. The over all goal is to be able to use values from the spreadsheet at imput into a webform. I am playing around with just using a loop to get the data into a MsgBox(), but I haven't even been able to get that to work.

Any ideas? Can this be done?

Edited by SlapshotBoston

Share this post


Link to post
Share on other sites
Edano

yes, sure. try the helpfile example:

; ***************************************************************
; Example 1 - Write to a Cell using a Loop, after opening a workbook and returning its object identifier.  Read the cells into an array, display array,
;               then Save and Close file.
; *****************************************************************

#include <Excel.au3>
#include <Array.au3>

Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

For $i = 1 To 5 ;Loop
    _ExcelWriteCell($oExcel, $i, $i, 1) ;Write to the Cell Vertically using values 1 to 5
Next

For $i = 1 To 5 ;Loop
    _ExcelWriteCell($oExcel, Asc($i), 1, $i + 2) ;Write to the Cell Horizontally, using Asc just to use different values for reading purposes
Next

Local $aArray1 = _ExcelReadArray($oExcel, 1, 1, 5, 1) ;Direction is Vertical
Local $aArray2 = _ExcelReadArray($oExcel, 1, 3, 5) ;Direction is Horizontal
_ArrayDisplay($aArray2, "Horizontal")
_ArrayDisplay($aArray1, "Vertical")

MsgBox(0, "Exiting", "Press OK to Save File and Exit")
_ExcelBookSaveAs($oExcel, @TempDir & "\Temp.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary
_ExcelBookClose($oExcel) ; And finally we close out

For $i = 0 To UBound($aArray2) - 1;      appended
    MsgBox(0,"",$aArray2[$i])
Next

For $i = 0 To UBound($aArray1) - 1
    MsgBox(0,"",$aArray1[$i])
Next

Edit: appended msgboxloops

E.

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

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  

×