Jump to content

Data Retrieval from Excel - (Moved)


Recommended Posts

Hi all,

I'm trying to make an AutoIt script for our windows application ,in which I need to extract values from multiple cells in excel and use those values for inserting in the text boxes and combo boxes in the application. Can anyone please tell me how should I make it happen? 

Link to comment
Share on other sites

I suggest you have a look at the Excel UDF that comes with AutoIt. Function _Excel_RangeRead should do what you are looking for.
If you need to extract a lot of cells it is best to read the whole worksheet into an array and then retrieve the needed information from the array - that's much faster compared to countless calls to _Excel_RangeRead :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Moved to the appropriate forum.

ShrutiW,

I am getting tired of moving your threads in to the correct section - you might find them vanishing in the future if you continue posting in inappropriate places.

M23

Edited by Melba23
Made it personal

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi @water, Thanks for the help, I have used excel UDF and now I am able to read the whole excel sheet.  But I am stuck in the next part, where I have to choose particular values from cells , say- Now I have to choose the row 1, I need values from cells- E1, F1, G1, P1 and R1 , and then retrieving these values and sending them to text boxes and combo boxes of another script.  I tried searching for it but no luck. Can you please help me in this please?

 

autoIt excel.PNG

Just posting the screenshot for better understanding . As there are multiple columns with headings like member Id , Inquire for .etc., What I want is, I need to check the first row, in which I will check for member Id first , and then check for next columns i.e. Inquire for and inquired about, if those fields contains yes, then retrieve that member Id, and paste it in another script (in the textbox field). Next going further, I will check for Inquiry type and contact type, will retrieve the values in the cells and selecting the given value matching with the comboBox in another script. I am not getting any idea how to do it. 😑 Please help?

Edited by ShrutiW
Link to comment
Share on other sites

Let's say you have read the whole worksheet into an array named $aUsedRange (and the used range in the sheet starts with column "A") then you will find the data you mentioned in

$sE1 = $aUsedRange[0][4] ; Cell E1
$sF1 = $aUsedRange[0][5] ; Cell F1
...

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

@ShrutiW

If you use _Excel_RangeRead() that reads the UsedRange from E to R columns, the function returns a 2-Dimension array, which you can iterate through, and extract only the values you're interested of.

On the other side, if you only need to extract 5 values (E1, F1, G1, P1 and R1), use _Excel_RangeRead() specifying the cells you want to read, and you're done.

18 minutes ago, ShrutiW said:

Could you please suggest  me a correct path to post my queries?

From the Forum Etiquette:

Quote

forum.

:)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Hi @water

I tried using usedRange function, but I am not getting how do I send the parameters retrieved from the cells in the another script? I am not getting any clue.  I have written a draft code, Can you please suggest me changes on how do I send values in particular cells to another script, and how will call the values in the new script , I use those values at runtime? 😞 

; Read the formulas of a cell range (all used cells in column A:R)
Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("1:18"), 1)
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 3 - Formulas in the worksheet.")
Local $sE1=0
$aUsedRange = _Excel_RangeRead($oWorkBook)
If $sE1 = $aUsedRange[0][17] Then
   Local $aResult1 = _Excel_RangeRead($oWorkbook, 1, "E2", 2)  
   ; Read the Member Id and send it to the text boxex in another script

ElseIf
$sF1 = $aUsedRange[0][5] And $sG1 = $aUsedRange[0][6] Then
Local $aResult2 = _Excel_RangeRead($oWorkbook, 1, "F1,G1", 2)
;If cell contains "Yes" then select a value from dropdown
EndIf

 

Edited by ShrutiW
Link to comment
Share on other sites

20 minutes ago, ShrutiW said:

how do I send the parameters retrieved from the cells in the another script?

Another AutoIt script? :)

If so, you could use Command Line parameters to pass values to the other script.

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Or you could use IPC (Inter Process Communication) to pass data between two scripts.
UDFs to implement IPC can be found here: https://www.autoitscript.com/wiki/User_Defined_Functions#Inter_Process_Communications

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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...