none
Opening and Extracting data from File in Web Server RRS feed

  • Question

  • hi,

     

    I'm trying to extract data from excel file and display them on a datagrid in the web page. i've used a simple code to allow users to upload excel files into the web server, the next step is for them to view the content of the excel file. can anyone advise me on this? i'm very new to web application, and is confused with so many ways to upload and view files through ADO.NET, SQL Server connection and many many more. what is the simplest approach that i can use? i've used a simple approach to upload the file into the server. below is my code.

     

    if ((File1.PostedFile != null) & File1.PostedFile.ContentLength > 0)

    {

    string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);

    string SaveLocation = Server.MapPath("Data") + "\\" + fn;

    try

    {

    File1.PostedFile.SaveAs(SaveLocation);

    Response.Write("The file has been uploaded.");

    }

    catch (Exception Exc)

    {

    Response.Write("Error: " + Exc.Message);

    }

    }

    else

    {

    Response.Write("Please select a file to upload.");

    }

    Monday, June 11, 2007 7:06 AM