Jump to content

Read Excel data


Recommended Posts

Hi, 

I searched a lot but couldn't find a solution, Please help me to sort out simple trick

I'd like to write a script ,which pick user name and password ,fill into a website and then wait for a function to complete and move to next row, I have tried many way but couldn't get through, If someone can please share the code, Shall be thankful,

Link to comment
Share on other sites

Hi, 

I searched a lot but couldn't find a solution, Please help me to sort out simple trick

I'd like to write a script ,which pick user name and password ,fill into a website and then wait for a function to complete and move to next row, I have tried many way but couldn't get through, If someone can please share the code, Shall be thankful,

Link to comment
Share on other sites

AutoIt comes with an Excel UDF, each function comes with an example script. _Excel_RangeRead should be a good starting point.

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

@water, thanks a lot for a prompt reply.

yes, that's the one , I am using, I am running the following code, it stops after reading all the cell, I'd like it read first cell and then enter these details to website,and then move to next cell. 

@water I am glad to see you here, I can see you are helping since 2008. I have already searched a lot,but couldn't the solution.please help.thanks a lot in advance

<autoit>

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


; Create application object
Local $oExcel = _Excel_Open()
Local $bReadOnly = False
Local $bVisible = True
Local $var = 1
Local $R = "D" & $var & ":" & "E" & $var
; ****************************************************************************
; Open an existing workbook and return its object identifier.
; *****************************************************************************
Local $sWorkbook = "D:\work\Variables\supplier\2016-2017\part01-31-07-2016.xlsx"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, $bReadOnly, $bVisible)
Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("D"), 1)
ConsoleWrite($aResult & @CRLF)
for $username In $aResult
   ConsoleWrite($username & @CRLF)
Next

</autoit>

Link to comment
Share on other sites

Try:

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

; Create application object
Local $oExcel = _Excel_Open()
Local $bReadOnly = False
Local $bVisible = True
Local $var = 1
Local $R = "D" & $var & ":" & "E" & $var
; ****************************************************************************
; Open an existing workbook and return its object identifier.
; *****************************************************************************
Local $sWorkbook = "D:\work\Variables\supplier\2016-2017\part01-31-07-2016.xlsx"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, $bReadOnly, $bVisible)
Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("D"), 1)
_ArrayDisplay($aResult)
For $i = 1 To UBound($aResult) - 1
    ConsoleWrite($aResult[$i] & @CRLF)
Next

 

Link to comment
Share on other sites

If the Excel worbook isn't too large I would read the whole sheet and then process th returned array:

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


; Create application object
Local $oExcel = _Excel_Open()
Local $bReadOnly = False
Local $bVisible = True
Local $var = 1
Local $R = "D" & $var & ":" & "E" & $var
; ****************************************************************************
; Open an existing workbook and return its object identifier.
; *****************************************************************************
Local $sWorkbook = "D:\work\Variables\supplier\2016-2017\part01-31-07-2016.xlsx"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, $bReadOnly, $bVisible)
Local $aResult = _Excel_RangeRead($oWorkbook)
For $i = 0 To UBound($aResult, 1) - 1
   Consolewrite($aResult[$i][3] & @CRLF) ; Column D
Next

 

Edited by water

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

@Subz, Thanks a lot, community is really excellent,but unfortunately I wasn't mean that, sorry if I couldn't  explain properly.

after reading first row, it assign value to a variable and then put value into website, after first cell completion ,it should pick the second value, I am attaching php code to explain. which I can achieve through php. $R will print before adding 1 to $var1. 

 $var1 = 1;

 

 while ($var1<=10){
      $R = "D";
    $C = "E$";
    echo "$R<br>";
    
    $var1++;
 }    

Link to comment
Share on other sites

Some questions regarding your PHP code:

  • Why do you increment $var1 in a loop and  then not use it in the loop?
  • The same is true for $C. It gets a string assigned but is not referenced in the loop.

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