472,127 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

asp and excel number problem

Hi,

I have a problem with reading from excel and displaying in an asp page. The numbers disapears.

My script:

<%
Const adOpenStatic = 3
Const adLockPessimistic = 2

Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols

' This is all standard ADO except for the connection string.
' You can also use a DSN instead, but so it'll run out of the
' box on your machine I'm using the string instead.
Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath("xl_data.xls") & ";IMEX=1;MAXSCANROWS=16;DRIVER={Microsoft Excel Driver (*.xls)};"

' Same as any other data source.
' FYI: TestData is my named range in the Excel file
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open "SELECT * FROM TestData;", cnnExcel, adOpenStatic, adLockPessimistic

' Get a count of the fields and subtract one since we start
' counting from 0.
iCols = rstExcel.Fields.Count
%>
<table border="1">
<thead>
<%
' Show the names that are contained in the first row
' of the named range. Make sure you include them in
' your range when you create it.
For I = 0 To iCols - 1
Response.Write "<th>"
Response.Write rstExcel.Fields.Item(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
%>
</thead>
<%
rstExcel.MoveFirst

' Loop through the data rows showing data in an HTML table.
Do While Not rstExcel.EOF
Response.Write "<tr>" & vbCrLf
For I = 0 To iCols - 1
Response.Write "<td>"
Response.Write rstExcel.Fields.Item(I).Value
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write "</tr>" & vbCrLf

rstExcel.MoveNext
Loop
%>
</table>

<%
rstExcel.Close
Set rstExcel = Nothing

cnnExcel.Close
Set cnnExcel = Nothing
%>

And the spreadsheed have the following
Item Item no Price
Philips32W ksjdf567 5000
Sony32XO 234jl 7000
Panasonic44 jkj323 12000
Dantax25 jhkh23 2200
Philips40W je983 32000
Philips25B jkw83k 2100
Philips25BX kdfj3 2300
Prosonic21 kdk4 1200
Sony32XO lksfj77 567
Sony44IN 88jdj 39000
Sony28W lkkdf84 56
Sony21XL 23423 3300
Prosonic25 234234 2400
Prosonic32 sdf4334 4400
Dantax32 32323 4400

The problem is that the numbers in the second column disapears if the cell is a number. How can I get asp to read and list all the data.
Dec 29 '06 #1
0 1316

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Matthew Wieder | last post: by
2 posts views Thread by Steve Chatham | last post: by
6 posts views Thread by Kevin Humphreys | last post: by
18 posts views Thread by gonzlobo | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.