Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extract data from EXCEl using ASP

    Below is my asp code:
    <%

    Set Conn = Server.CreateObject("ADODB.Connection")
    str = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" & Server.MapPath("/chart/test.xls")
    Conn.Open str

    Set rs = Server.CreateObject("ADODB.Recordset")
    SQL ="SELECT * FROM testsheet"
    rs.Open SQL, Conn
    rs.movefirst
    do while not rs.eof
    response.Write(rs("test")&" | "&rs("test1")& " & "<br>")
    rs.movenext
    Loop
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing
    %>
    The error is:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
    [Microsoft][ODBC Excel Driver] Microsoft Jet can't find the testsheet object...
    Can somebody tell me where am i wrong?
    Or somebody can show me an easy example about using ASP to extract data and display Excel data?
    The attachted pic is the test.xls
    Attached Thumbnails Attached Thumbnails Extract data from EXCEl using ASP-xls.jpg  

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    when using excel as a database, you have to define a named range in the sheet, which ado will treat as a table

    select your cells, select the insertmenu, click name, click define, enter "testsheet", save the sheet.

    now it should work
    I am the luckiest man in the world

  • #3
    New Coder
    Join Date
    Nov 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,Roelf,
    Can you explain more in detail?
    In face,testsheet is a worksheet in test.xls,so my sql is
    "select * from testsheet",is this not correctly?

  • #4
    New Coder
    Join Date
    Nov 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm...i have work it out,but i still have a question.
    Does it must select the range of cell,insert the range,define the range,name the range,and add the range?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •