Jump to content

Accessing Data in an array from Excel


Recommended Posts

Hello,

Is there a way wherein I can access the data from an array coming from an Excel file then have it assigned on to a variable?

Below is a snippet of my current code. For now, it just reads and outputs the data from the excel file and have it displayed via an array.

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

Local $oExcel = _Excel_Open(False)
    If @error Then Exit MsgBox(0, "Error", "Error creating application object." & @CRLF & "Error: " & @error & " Extends: " & @extended)

; Open Excel Woorkbook and return object
Local $sWorkbook = @ScriptDir & "\Excel Files\Test Data.xlsx"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, False, True)
    If @error Then
        MsgBox(0, "Error", "Error opening workbook'" & $sWorkbook & ".'" & @CRLF & "Error: " & @error & "Extends: " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf

Local $aResult = _Excel_RangeRead($oWorkbook)
    ; Error Trapping
    If @error Then
        MsgBox(0, "Error", "Error reading data from '" & $sWorkbook & ".'" & @CRLF & "Error: " & @error & " Extends: " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf
_ArrayDisplay($aResult)

My Excel file has values from Column A to H with values from 1 to 30, what I desired to do is have the value in "A7" assigned on to a variable. 

 

Any help is appreciated. Thanks in advance.

Link to comment
Share on other sites

Quite easy ;)

$sResult = _Excel_RangeRead($oWorkbook, Default, "A7")

 

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

  • Moderators

@Eminence welcome to the forum, but please pay attention to where you post in the future. The DEV forum very clearly states:

 

Quote

Do not create AutoIt-related topics here, use AutoIt General Help and Support

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

20 hours ago, water said:

Quite easy ;)

$sResult = _Excel_RangeRead($oWorkbook, Default, "A7")

 

Oh lol. Thanks! :D

19 hours ago, JLogan3o13 said:

@Eminence welcome to the forum, but please pay attention to where you post in the future. The DEV forum very clearly states:

 

 

My bad. Will do next time. Thank you! 

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

×
×
  • Create New...