Excel Import to HTML/ASP Page

J

J medina

I have an ASP Script that imports an Excel Page to a HTML page. The
problem I have that it displays all cells that have only numbers in it
but not for numbers that precedes a letter (i.e. 12345 is displayed,
but M12345 is not)

This is some of the code:

oConn.Open "testXLS"
'Where testXLS is the ODBC Excel DSN

'Selects the records from the Excel spreadsheet

strCmd = "SELECT * from [Dta$]"
'where Dta is the worksheet name

Set oRS = Server.CreateObject("ADODB.Recordset")
'It opens the recordset

oRS.Open strCmd, oConn

Do While not oRS.EOF
Response.Write oRS.Fields.Item(0).Value
Response.Write oRS.Fields.Item(1).Value
oRS.MoveNext
Loop
oRS.Close

Thanks for your help...
 
R

Ray at

If you switch to an OLEDB connection string, I believe you will get all the
cells. Try code like this:

<%
Dim oConn, oRS
Dim strCmd

strCmd = "SELECT * FROM [Dta$]"

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\Path\To\The\Excel\file.xls;Extended Properties=""Excel
8.0;HDR=Yes;IMEX=1"
Set oRS = oConn.Execute(strCmd)

Do While Not oRS.EOF
Response.Write oRS.Fields.Item(0).Value
Response.Write oRS.Fields.Item(1).Value
Loop
oRS.Close
Set oRS = Nothing

oConn.Close
Set oConn= Nothing
%>

Note that you'll have to update the path to your Excel file, as it exists on
the server.

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top