Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding out programmatically how many rows in excel.
Message
From
27/01/2003 21:53:13
Jacci Adams
Lindsay-Adams Consulting
Louisville, Ohio, United States
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00745897
Message ID:
00746069
Views:
22
Hi,

I just gave you a snapshot. Below is more detail. The code below is just a sample. It isn't going to be code you can take and directly apply to your application. It shows some different approaches to your problem.

This piece of code opens a file called 'Open Order Report.xls' the creator of this .XLS file knows to put "SHEETEND" into the last Row of Column lnSymbolCol to flag that there are no more rows to check. lnSymbolCol is the holder of the a passed parameter.

loxls = This.oCOMServer
lcOpenOrdersFile = GETFILE('XLS', 'Open Order Report.xls')

WITH loxls
.Workbooks.Open(lcOpenOrdersFile)
.Range("A3").Select
.Visible = .T.
lnRow = 3

lcSymbol = .Cells(lnRow, lnSymbolCol).VALUE

DO WHILE TYPE( 'lcSymbol' ) <> 'C' && skip over the empty cells
lnRow = lnRow + 1
lcSymbol = .Cells(lnRow, lnSymbolCol).VALUE
ENDDO

DO WHILE lcSymbol <> "SHEETEND"

.Range("S"+ ALLTRIM(STR(lnRow,5)) ).Select

ldOpenDate = .Cells(lnRow, lnOpenDateCol).VALUE
lnRow = lnRow + 1
lcSymbol = .Cells(lnRow, lnSymbolCol).VALUE
DO WHILE TYPE( 'lcSymbol' ) <> 'C'
lnRow = lnRow + 1
lcSymbol = .Cells(lnRow, lnSymbolCol).VALUE
ENDDO

ENDDO

.ActiveWorkbook.SaveAs(lcOpenOrdersFile,-4143, "", "", .F., .F. )
.Activeworkbook.close()

ENDWITH

HTH,
Jacci

>Nope this code did not work...I got errors that the lcSymbol=..... must be within and with/endwith...
>
>I guess I will keep plugging...I did post my code above if you can check it out maybe you could help more....Thanks again....
Previous
Reply
Map
View

Click here to load this message in the networking platform