Excel Import to HTML/ASP Page

Discussion in 'ASP General' started by J medina, Sep 16, 2003.

  1. J medina

    J medina Guest

    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...
     
    J medina, Sep 16, 2003
    #1
    1. Advertising

  2. J medina

    Ray at Guest

    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




    "J medina" <> wrote in message
    news:...
    > 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
    >
     
    Ray at, Sep 17, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jake
    Replies:
    1
    Views:
    705
    Ian Oldbury
    Apr 7, 2004
  2. =?Utf-8?B?U2l1?=

    Export and Import from Excel into a Web page

    =?Utf-8?B?U2l1?=, Feb 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    13,970
  3. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,604
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  4. Chuck
    Replies:
    0
    Views:
    283
    Chuck
    Jul 5, 2003
  5. fniles
    Replies:
    6
    Views:
    684
    Karl E. Peterson
    Apr 27, 2009
Loading...

Share This Page