ajit Posted January 14, 2009 Share Posted January 14, 2009 (edited) HiI have made a script to read lines from an Excel sheet and then give the total through a Msgbox. Is there another way to write this script. Please help me.Thanking in anticipation.AjitScript:$file = FileOpen("1.xls", 0)If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitEndIf$val1 = FileReadLine($file, 1) $val2 = FileReadLine($file, 2)$val3 = FileReadLine($file, 3)$val4 = FileReadLine($file, 4)$val5 = FileReadLine($file, 5)$val6 = FileReadLine($file, 6) $val7 = FileReadLine($file, 7)$val8 = FileReadLine($file, 8)$val9 = FileReadLine($file, 9)$val10 = FileReadLine($file, 10);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;$valn = FileReadLine($file, "line N")$total = $val1 + $val2 + $val3 + $val4 + $val5 + $val6 + $val7 + $val8 + $val9 + $val10MsgBox(1, "Total Value", $total);; Thanks I am really sorry I put this in the wrong forum Edited January 14, 2009 by ajit Link to comment Share on other sites More sharing options...
Aceguy Posted January 14, 2009 Share Posted January 14, 2009 look at #Include <File.au3> _FileCountLines($sFilePath) in the helpfile [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
ajit Posted January 14, 2009 Author Share Posted January 14, 2009 look at #Include <File.au3> _FileCountLines($sFilePath) in the helpfile @Aceguy Thanks for your reply but what I need is the values in the lines, not the number of lines. If I am not wrong your suggestion gives the number of lines. Thanks again Ajit Link to comment Share on other sites More sharing options...
rasim Posted January 15, 2009 Share Posted January 15, 2009 (edited) @ajitSee a Excel Management in the help file. Example:#Include <Excel.au3> #Include <Array.au3> $oExcel = _ExcelBookOpen(@ScriptDir & "\test.xls") $aArray1 = _ExcelReadArray($oExcel, 1, 1, 10, 1) ;Direction is Vertical $aArray2 = _ExcelReadArray($oExcel, 1, 2, 10, 0) ;Direction is Horizontal _ArrayDisplay($aArray2, "Horizontal") _ArrayDisplay($aArray1, "Vertical") _ExcelBookClose($oExcel) Edited January 15, 2009 by rasim Link to comment Share on other sites More sharing options...
ajit Posted January 15, 2009 Author Share Posted January 15, 2009 @ajit See a Excel Management in the help file. Example: #Include <Excel.au3> #Include <Array.au3> $oExcel = _ExcelBookOpen(@ScriptDir & "\test.xls") $aArray1 = _ExcelReadArray($oExcel, 1, 1, 10, 1) ;Direction is Vertical $aArray2 = _ExcelReadArray($oExcel, 1, 2, 10, 0) ;Direction is Horizontal _ArrayDisplay($aArray2, "Horizontal") _ArrayDisplay($aArray1, "Vertical") _ExcelBookClose($oExcel) @rasim Thanks a lot for your reply. I think i was working on an older version of AutoIT thus the problem. I work on Win98 so new versions could not be used. Thanks again for your help. Regards Ajit Link to comment Share on other sites More sharing options...
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