Sign in to follow this  
Followers 0
powaking

Help with Excel Array

3 posts in this topic

Hello fellow Autoit scriptors. Its been a long time since I've needed to use AutoIt (job change). At the time we had a fully implemented support tool used across the country which assisted with remote support of our customers. But that ship has sailed (about 4 years ago) and much has changed. I'm recently in a new role and I see the need to utilize AutoIt but as you may have guessed it you either use it or lose it and I lost it.

My request for assistance is I need to have a script read an Excel spreadsheet so that I can select 1 column from a dropdown box and have it display information pertaining to that row in other variables. I'm able to read the excel file into an array and then display the array but working within the array is where I'm stuck. There are about 170 rows and 17 columns of which I probably only need to work with 3-4 columns. Making the GUI is not the issue its just working out the array is where I need some assistance.

Here is what I have so far. I also noticed that even after closing the sheet there's still an instance of Excel running, anyway to have that close out gracefully?

Thanks!!!

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

Local $oExcel = _ExcelBookOpen("c:\ExcelFile.xlsx",0,True)
;Local $oExcel=_ExcelBookOpen("c:\ExcelFile.xlsx")

$aArray = _ExcelReadSheetToArray($oExcel,3,1,0,17)

_ArrayDisplay ($aArray,"Sheet:",-1)

_ExcelBookClose($oExcel)

Exit

Share this post


Link to post
Share on other sites



Release the object and Excel should be gone after closing.

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

Local $oExcel = _ExcelBookOpen("c:\ExcelFile.xlsx",0,True)
;Local $oExcel=_ExcelBookOpen("c:\ExcelFile.xlsx")

$aArray = _ExcelReadSheetToArray($oExcel,3,1,0,17)

_ArrayDisplay ($aArray,"Sheet:",-1)

_ExcelBookClose($oExcel)
$oExcel = 0  ; <==

Exit

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Release the object and Excel should be gone after closing.

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

Local $oExcel = _ExcelBookOpen("c:\ExcelFile.xlsx",0,True)
;Local $oExcel=_ExcelBookOpen("c:\ExcelFile.xlsx")

$aArray = _ExcelReadSheetToArray($oExcel,3,1,0,17)

_ArrayDisplay ($aArray,"Sheet:",-1)

_ExcelBookClose($oExcel)
$oExcel = 0  ; <==

Exit

Unfortunately that didn't work. I'll try to figure out how to kill the excel process but still would like some help with working with the Array and again only certain columns.

TIA

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