Jump to content

Read data from specific Row


Recommended Posts

Hi AutoITers,

I have a basic question, I have an excel worksheet with a lot of data in it, but I only want to acquire the data of the entire ROW? Is there any possible way to do this? I tried using _Excel_RangeRead with parameter of ROW but no value was acquired.

Func doCountermeasure()

    Local $oExcel  = _Excel_Open(False)
    Local $testdesign = _Excel_BookOpen( $oExcel, StringTrimLeft(FileReadLine  ( $errorlogFile, 2 ), 20), True, True ) ;open test sheet loaded in FSUnit tool
    Local $aWorkSheets = _Excel_SheetList($testdesign) ;list worksheets of the test design
    Local $file = @ScriptDir & "\TempFile.txt" ;create temporary text file
    FileOpen($file, 2)
    Local $worksheets = _FileWriteFromArray  ( $file, $aWorkSheets ) ;populate text file with name of worksheets
    Local $aInput

    _FileReadToArray($file, $aInput)

    For $i = 3 to UBound($aInput) - 2 ;loop to different worksheets
        ;MsgBox (0,'',$aInput[$i])StringTrimRight( $aInput[$i], 1)
        Local $factors = _Excel_RangeRead ( $testdesign, StringTrimRight( $aInput[$i], 1), "E26") ;gather data from row E26 of each worksheets
        _ArrayDisplay ($factors)
    Next
    _Excel_BookClose ( $testdesign )
    ;FileDelete( $file )

EndFunc

Thank you!

 

 

Link to comment
Share on other sites

Just now, CiaronJohn said:

Hi AutoITers,

I have a basic question, I have an excel worksheet with a lot of data in it, but I only want to acquire the data of the entire specific ROW? Is there any possible way to do this? I tried using _Excel_RangeRead with parameter of ROW but no value was acquired.

Func doCountermeasure()

    Local $oExcel  = _Excel_Open(False)
    Local $testdesign = _Excel_BookOpen( $oExcel, StringTrimLeft(FileReadLine  ( $errorlogFile, 2 ), 20), True, True ) ;open test sheet loaded in FSUnit tool
    Local $aWorkSheets = _Excel_SheetList($testdesign) ;list worksheets of the test design
    Local $file = @ScriptDir & "\TempFile.txt" ;create temporary text file
    FileOpen($file, 2)
    Local $worksheets = _FileWriteFromArray  ( $file, $aWorkSheets ) ;populate text file with name of worksheets
    Local $aInput

    _FileReadToArray($file, $aInput)

    For $i = 3 to UBound($aInput) - 2 ;loop to different worksheets
        ;MsgBox (0,'',$aInput[$i])StringTrimRight( $aInput[$i], 1)
        Local $factors = _Excel_RangeRead ( $testdesign, StringTrimRight( $aInput[$i], 1), "E26") ;gather data from row E26 of each worksheets
        _ArrayDisplay ($factors)
    Next
    _Excel_BookClose ( $testdesign )
    ;FileDelete( $file )

EndFunc

Thank you!

 

 

 

Link to comment
Share on other sites

The .EntireRow method is the way to go. Please post the code you used that does not work. 

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

One last comment:
The wiki is a good source: https://www.autoitscript.com/wiki/Excel_Range#Entire_Row_.2F_Entire_Column

 

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

Simply use _Excel_RangeRead to read this 4 columns. Merged cells will be returned in the leftmost cell of the array.

Means: You read columns K:N the string "expected values" would be returned in row 23, column 0 of the returned array.

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