Logu Posted April 16, 2011 Posted April 16, 2011 Hi,iam new to AutoIt, I need to open excel and want to read the data and want to match date with system team and want to alert if system date is going to match with excel date. I tried this code can any one suggest code to me to complete this task #include <excel.au3>#include <array.au3> $file = @ScriptDir & "\excel.xls"$oExcel = _ExcelBookOpen($file, 0) ; $aArray = _ExcelReadSheetToArray($oExcel, 2) ;_ArrayDisplay($aArray, "Array using Default Parameters") For $i = 1 to UBound($aArray)-1 $a1name = $aArray[$i][1] $a2date = $aArray[$i][2] MsgBox(0,'debug', $a1name &' '& $a2date ) Next $date = @MON & "/" & @MDAY & "/" & @YEAR;I need to check this date with a2date which is taken in excel._ExcelBookClose($oExcel) ; close excel
JoHanatCent Posted April 16, 2011 Posted April 16, 2011 Hi, iam new to AutoIt, I need to open excel and want to read the data and want to match date with system team and want to alert if system date is going to match with excel date. I tried this code can any one suggest code to me to complete this task Do the comparison in the same format. This should work: #include <excel.au3> #include <array.au3> $file = @ScriptDir & "\excel.xls" $oExcel = _ExcelBookOpen($file, 0) ; $aArray = _ExcelReadSheetToArray($oExcel, 2) ; _ArrayDisplay($aArray, "Array using Default Parameters") For $i = 1 to UBound($aArray)-1 ;$a1name = $aArray[$i][1] If $aArray[$i][2] = @YEAR & @MON & @MDAY & "000000" Then; Test current date against Correct format MsgBox(0, '', 'Same date in line ' & $i & @CRLF & $aArray[$i][1] & " = " & @MON & "/" & @MDAY & "/" & @YEAR) EndIf ;$a2date = $aArray[$i][2] ;MsgBox(0,'debug', $a1name &' '& $a2date ) Next $date = @MON & "/" & @MDAY & "/" & @YEAR ;I need to check this date with a2date which is taken in excel. _ExcelBookClose($oExcel) ; close excel
Logu Posted April 16, 2011 Author Posted April 16, 2011 Do the comparison in the same format. This should work: #include <excel.au3> #include <array.au3> $file = @ScriptDir & "\excel.xls" $oExcel = _ExcelBookOpen($file, 0) ; $aArray = _ExcelReadSheetToArray($oExcel, 2) ; _ArrayDisplay($aArray, "Array using Default Parameters") For $i = 1 to UBound($aArray)-1 ;$a1name = $aArray[$i][1] If $aArray[$i][2] = @YEAR & @MON & @MDAY & "000000" Then; Test current date against Correct format MsgBox(0, '', 'Same date in line ' & $i & @CRLF & $aArray[$i][1] & " = " & @MON & "/" & @MDAY & "/" & @YEAR) EndIf ;$a2date = $aArray[$i][2] ;MsgBox(0,'debug', $a1name &' '& $a2date ) Next $date = @MON & "/" & @MDAY & "/" & @YEAR ;I need to check this date with a2date which is taken in excel. _ExcelBookClose($oExcel) ; close excel Thank you very much dear friend!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now