Jump to content

Getting Excel Row Count


Recommended Posts

Hello to All!!

I'm trying to automate the writing of Oracle SQL-Plus Insert statements and I'm having a problem with the "_ExcelSheetUsedRangeGet" function in _ExcelCom. I reviewed the function comments and thought I was using it correctly, but it always seems to return a zero for the number of rows. The code that I'm using is below. As I said, I keep getting "0" returned for the last row number and I'm positive that there are 15 rows used in the sheet. I apperciate any help I can get with this.

Thanks & have a great day,

PJ

Local $oExcel = _ExcelBookOpen($Get_In_Fyle, 1)

Dim $Num_Rows[4]

$CurrRow = 1

$Record_Cnt = 0

$Num_Rows = _ExcelSheetUsedRangeGet($oExcel, 1)

SplashTextOn("DeBug","Last Cell Used " & $Num_Rows[0] & @CRLF & "Last Cell Used " & $Num_Rows[1] & @CRLF & "Last Col Used " & $Num_Rows[2] & @CRLF & "Number of rows = " & $Num_Rows[3], 500, 200, -1, 50, 4, "", 12)

Sleep(300)

MsgBox(4096,"DeBug", "Number of rows = " & $Num_Rows[3])

; MsgBox(4096,"DeBug", "Control Number = " & $Ctrl_No)

For $Cell = 1 to $Num_Rows[3]

$Ctrl_No = _ExcelReadCell($oExcel, $Cell, 1)

MsgBox(4096,"DeBug", "Control # = " & $Ctrl_No & @CRLF & "Cell # = " & $Cell& @CRLF & "Number of rows = " & $Num_Rows[3])

FileWriteLine($Insert_Fyle,"Insert into Reset_Tmp_CNUM (C_Num) values ('" & $Ctrl_No & "')" & @CRLF)

$Record_Cnt = $Record_Cnt + 1

Next

; And finally we close out

_ExcelBookClose($oExcel)

FileClose($Insert_Fyle)

MsgBox(4096,"Insert Create", "Insert file created -- " & $Record_Cnt & " records written!")

Link to comment
Share on other sites

I answered your other post as well. What you need is the new UDF I just uploaded. Grab it from the link at my signature.

-S

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
Link to comment
Share on other sites

I answered your other post as well. What you need is the new UDF I just uploaded. Grab it from the link at my signature.

-S

Thanks! I didn't mean to be a pain. I just figured that if you were busy at the moment someone else might have the answer. I've downloaded the new UDF and will give it a try in a little bit.

Thanks again & have a great week,

PJ

Link to comment
Share on other sites

I understand the desire to "cover all bases." :whistle:

Good luck with your Excel endeavors, and feel free to IM me with any Excel-related AutoIt questions.

-S

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
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...