R
raz230
I am learning some excel programming for use in a ASP web site. I need
to select a range of cells and then process what I select. I am
getting along OK with that part, but how can I determine what to select
so that I avoid selecting rows that don't have any data?
EG, I have columns "A" through "O" to work with. There is some header,
title and report title text and basically some non-related things at
the top of the worksheet. Data starts at [A9]
If I knew that the report always ended at line 500, I could select
[A9:O500]- but the report varies in length.
here is a code sample of what I am doing: Any advice would be much
appreciated.
I am constrained by circumstances to use ASP.
Dim ExcelConn
Set ExcelConn = Server.CreateObject("ADODB.Connection")
With ExcelConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open Server.mappath("/Reports/Processing/ImportedInvoices/test.xls")
.Properties("Jet OLEDB:Max Buffer Size") = 256
End With
Dim objRs
Set objRs = Server.CreateObject("ADODB.Recordset")
With objRs
Set .ActiveConnection = ExcelConn
.Open "Select * from [Sheet1$A9:O500]" 'how do I know what to
select???
End With
Do While NOT objRs.EOF
Response.Write objRs.Fields.Item(0) & " " & objRs.Fields.Item(1) &
"<br>"
objRs.MoveNext
Loop
objRs.Close
Set objRs = Nothing
ExcelConn.Close
Set ExcelConn = Nothing
to select a range of cells and then process what I select. I am
getting along OK with that part, but how can I determine what to select
so that I avoid selecting rows that don't have any data?
EG, I have columns "A" through "O" to work with. There is some header,
title and report title text and basically some non-related things at
the top of the worksheet. Data starts at [A9]
If I knew that the report always ended at line 500, I could select
[A9:O500]- but the report varies in length.
here is a code sample of what I am doing: Any advice would be much
appreciated.
I am constrained by circumstances to use ASP.
Dim ExcelConn
Set ExcelConn = Server.CreateObject("ADODB.Connection")
With ExcelConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open Server.mappath("/Reports/Processing/ImportedInvoices/test.xls")
.Properties("Jet OLEDB:Max Buffer Size") = 256
End With
Dim objRs
Set objRs = Server.CreateObject("ADODB.Recordset")
With objRs
Set .ActiveConnection = ExcelConn
.Open "Select * from [Sheet1$A9:O500]" 'how do I know what to
select???
End With
Do While NOT objRs.EOF
Response.Write objRs.Fields.Item(0) & " " & objRs.Fields.Item(1) &
"<br>"
objRs.MoveNext
Loop
objRs.Close
Set objRs = Nothing
ExcelConn.Close
Set ExcelConn = Nothing