www.webdeveloper.com
Results 1 to 6 of 6

Thread: How can I Open an Excel file in ASP?

  1. #1
    Join Date
    Feb 2004
    Location
    Mexico City
    Posts
    63

    Question How can I Open an Excel file in ASP?

    Hi there.

    I need to "upload" data to my db in SQL. The data is on Excel files and the app is on the intranet, programmed in ASP.

    I need the user to upload the excel file to the server... and then, the server must process the file in order to validate data in it and, if it is correct, server must insert the info to my SQL DB.

    I know how to generate an Excel file to appear opened in browser to the user... but that is not what I need. The user already has the file, I only need the server to process the file with my algorithm to validate and extract the info to my DB.

    Any help will be highly appreciated.

    Thanx.
    Freedom consists in doing what you want. The real problem is to know what you want...

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    This takes two steps... First, the file must be uploaded. Then, you can use ADODB to open the Excel workbook as if it were a database. Each sheet within the workbook is treated as its own data table.

    What do you need to know more about?

  3. #3
    Join Date
    Feb 2004
    Location
    Mexico City
    Posts
    63

    Thank You!!

    Thank you very much.

    Now... next question. I know how to make a connection to an ODBC... then I link all my ADODB commands and recordsets with this connection...

    How do I make a connection to an Excel file???

    I assume then that once the connection is made, recordsets and commands will work exactly the same way, rigth?
    Freedom consists in doing what you want. The real problem is to know what you want...

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    Quote Originally Posted by CybIRO
    I assume then that once the connection is made, recordsets and commands will work exactly the same way, rigth?
    Pretty much, yep, that's it. Here is where you can find all kinds of connection strings:

    Connectionstrings.com

  5. #5
    Join Date
    Feb 2004
    Location
    Mexico City
    Posts
    63

    Thumbs up It Works Perfectly

    Thank you very much!!!!

    It works perfectly.

    I require it to be a dynamic file... and in order to work properly, in the connection line it requires the absolute path on the server. I still don't find the way to use relative paths such as "../MyFile.xls" instead of "c:\Myfolder\MyFile.xls" but... it works anyway.

    Freedom consists in doing what you want. The real problem is to know what you want...

  6. #6
    Join Date
    Dec 2004
    Posts
    8,637
    Code a relative path from the root folder of your site and have it dynamically converted to a physical path as follows:

    Server.MapPath("/folder/MyFile.xls")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles