Jump to content

Help with Excel Array


Recommended Posts

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

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...