GridView to Excel then Excel to database table.

Discussion in 'ASP .Net' started by mohaaron@gmail.com, Nov 6, 2007.

  1. Guest

    Has anyone else tried to save a GridView as a excel file and then use
    ado.net to read the excel sheet back into a database table?

    I'm having a terrible time trying to make this work. The normal method
    of doing this using OleDb and a connection string like the following
    doesn't work on a Excel file that has been created from a GridView.

    Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + file + "; Extended
    Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

    When doing this ado.net throws the following error.

    "External table is not in the expected format."

    I did a little research and found that the Excel sheet is in the
    format of a html table which this connection string won't work with. I
    then found another post where someone was using "Extended
    Properties=HTML Import" but when I use this I get a different error.

    "The Microsoft Jet database engine could not find the object
    'Sheet1$'. Make sure the object exists and that you spell its name
    and the path name correctly."

    So I'm now stuck and can't make this work. Any idea's would be greatly
    appreciated.

    Thanks.
    , Nov 6, 2007
    #1
    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. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,379
    Carl Prothman [MVP]
    Jan 12, 2005
  2. D
    Replies:
    3
    Views:
    684
    Mark Rae
    Sep 3, 2006
  3. Andy

    Query database, then export to Excel VB.NET

    Andy, May 11, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    631
    Andy Bolk
    May 14, 2004
  4. Renie83
    Replies:
    2
    Views:
    232
  5. Replies:
    0
    Views:
    270
Loading...

Share This Page