We help IT Professionals succeed at work.
Get Started

Data extraction from excel problem

claracruz
claracruz asked
on
376 Views
Last Modified: 2012-05-05
Hi Experts,

I am having a strange problem, and I am hoping that someone somewhere has exprienced this before.

I am retrieving data from excel and writing it to the page with the following code (see attached code snippet).
All works fine, except that two columns behave very strangely. On one Column, when a cell contains  numbers like the following;- 38, 32, 42, it is displayed but where the cell contains data like so;- 7.9M, 10.5M, -180K the data is not displayed. To make things even stranger, on another column the reverse is the case, that is numbers (38, 32, 42) are displayed, but data like so ( 7.9M, 10.5M, -180K) are not...

pls find attached the excel file.

Any help appreciated


dim objConn, objRS
	Set objConn = Server.CreateObject("ADODB.Connection")
	objConn.Provider = "MSDASQL"
 
	objConn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=ADOtest2";ReadOnly= false;"
	objConn.Open
	
	
	
	Set objRS = Server.CreateObject("ADODB.Recordset")
	objRS.ActiveConnection = objConn
	objRS.CursorType = 3                    'Static cursor.
	objRS.LockType = 2                      'Pessimistic Lock.
	objRS.Source = "Select * from myRange1"
	objRS.Open
dim X
	Response.Write("<TABLE><TR>")
      For X = 0 To objRS.Fields.Count - 1
         Response.Write("<TD>" & objRS.Fields.Item(X).Name & "</TD>")
      Next
      Response.Write("</TR>")
      objRS.MoveFirst
 
      While Not objRS.EOF
         Response.Write("<TR>")
         For X = 0 To objRS.Fields.Count - 1
            Response.write("<TD>" & objRS.Fields.Item(X).Value)
         Next
         objRS.MoveNext
         Response.Write("</TR>")
      Wend
      Response.Write("</TABLE>")
	Destroy objRS 'custom function
	objConn.close

Open in new window

ADOtest2.xls
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE