Jump to content

Populating Arrays from Excel


Recommended Posts

Hi all,
 
I am working on a data entry utility to enter large amounts of data into a piece of software. My data lives in a series of excel spreadsheets each with 6 columns and 100 rows (the software into which I'm entering my data has a limit of 100 rows per entry).
 
I'm having a hard time getting my arrays to populate with data from Excel. Here's what I've got set up:

;; Populate arrays with CDM charge info from excel doc
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel,@DesktopDir & "\AutoItTest.xlsx")
Sleep(2000)

Local $aProcedure = _Excel_RangeRead($oExcel,Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A"),1)

I then repeat this for each of my other 5 columns of data.

Based on the information in Help, I take this to populate my $aProcedure array with all of the contents in column A.

Please help! Thank you!

Link to comment
Share on other sites

  • Moderators

This works just fine for me:

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

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xls")

Local $aArray = _Excel_RangeRead($oWorkbook, Default, "A:A")
    _ArrayDisplay($aArray)

Edit: Sorry, I missed that you're trying to get used range only...

Modified, this works for me:

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

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xls")

Local $aArray = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.UsedRange.Columns("A:A"))
    _ArrayDisplay($aArray)



Edited by JLogan3o13

"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

Parameter 1 for function_Excel_RangeRead should be the workbook object, not the Excel application object.

Means: Replace $oExcel with $oWorkbook

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

:)

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

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