Jump to content

Need small help to read excel cell .


Recommended Posts

Dear Team,

I am creating one script it should read the content of Ms excel cell if content is there script should process .If content is not there in cell script should exit with msg box .

Here is the code  .could you please help me in the same  .

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

Local $oExcel = _ExcelBookOpen("d:\ani.xls",0)
;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

;For $i = 1 To 5 ;Loop
   ; _ExcelWriteCell($oExcel, $i, $i, 1) ;Write to the Cell
;Next

Local $sCellValue, $sCellValue1 ,$splitsrname1,$splitsrnameyear,$splitsrnamedate,$splitsrnamemonth,$splitsrnamemonth1
For $i = 2 To 3
;Loop
    $sCellValue = _ExcelReadCell($oExcel, $i, 1)
    $sCellValue1 = _ExcelReadCell($oExcel, $i, 2)
    $splitsrname1 = StringLeft($sCellValue1, 8)
    $splitsrnameyear = StringLeft($splitsrname1,4)
    $splitsrnamedate = Stringright($splitsrname1,2)
    $splitsrnamemonth =Stringright($splitsrname1,4)
    $splitsrnamemonth1 =StringLeft($splitsrnamemonth,2)
    dim $DOB =$splitsrnamedate&$splitsrnamemonth1&$splitsrnameyear
    MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $sCellValue, 2)
    MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $splitsrnameyear , 2)
    MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $splitsrnamedate  , 2)
    MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $splitsrnamemonth1 , 2)
    MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $DOB, 2)
    if $sCellValue =" " then
       MsgBox($MB_SYSTEMMODAL, "test", "there is no data in cell now exit")
       Exit
     EndIf
Next
Edited by Andy2520
Link to comment
Share on other sites

Doesn't look bad. What doesn't 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

Could you test for cells with no content ("")? Now you test for cells with a space as content:

if $sCellValue = "" then
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

:)

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

×
×
  • Create New...