Jump to content
attractiveguy

Read Excel data

Recommended Posts

attractiveguy

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,

Share this post


Link to post
Share on other sites
attractiveguy

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,

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

Merged posts


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
attractiveguy

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

Share this post


Link to post
Share on other sites
attractiveguy

@JLogan3o13, not sure,how I posted second time,thanks for merging,

Share this post


Link to post
Share on other sites
Subz

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

 

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
attractiveguy

@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++;
 }    

Share this post


Link to post
Share on other sites
attractiveguy

@water, Unfortunately code is not stopping to assign value  to a variable.  it just keep reading until end.

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
attractiveguy

Please forget the $C,  I am assign $var1 to $R. $R is equal to"D(coloumn)$var1"; so by changing $var1 value, I am going to next row each time. 

Share this post


Link to post
Share on other sites
attractiveguy

Okay, I think ,I have figured it out. But the support from the community is excellent. I really appreciate all you guys for help me this, I spent two days to figure it out. Special thanks to @water and @Subz

Share this post


Link to post
Share on other sites
water

:)

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


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

×