Jump to content

Total from columns (excel sheet)


ajit
 Share

Recommended Posts

Hi

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

Ajit

Script:

$file = FileOpen("1.xls", 0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

$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 + $val10

MsgBox(1, "Total Value", $total)

;; Thanks

I am really sorry I put this in the wrong forum

Edited by ajit
Link to comment
Share on other sites

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

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

:)

Edited by rasim
Link to comment
Share on other sites

@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

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