Uploading Excel file into sql table

Discussion in 'Software' started by shalim, Oct 19, 2006.

  1. shalim

    shalim

    Joined:
    Oct 19, 2006
    Messages:
    1
    Dear all,

    I am developing a web application, with one sub web page is to upload excel file into sql data table using FileUpload control
    The scenario is as below :

    1. User clicks on browse button of the FileUpload control and selects the excel file to upload in the local pc
    2. The file name is captured and saved into a Dataset.
    3. The Dataset is Bound to a Gridview to show the worksheet of the excel file
    4. Then the user press button to upload the file to sql table in server

    How can I implement this scenario using ASP.NET (VS2005) and VB script


    Thanks for any response
     
    shalim, Oct 19, 2006
    #1
    1. Advertising

  2. shalim

    lahiruslk

    Joined:
    Oct 31, 2006
    Messages:
    1
    Reply with C#

    try
    {

    Excel.Application excelObj = new Excel.Application();
    string workbookPath = "c:/dbExcel/25-10-2006.xls";
    Excel.Workbook theWorkbook = excelObj.Workbooks.Open(workbookPath, 0, true, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
    Excel.Sheets excelSheets = theWorkbook.Worksheets;
    string currentSheet = txtsheet.Text.ToString().Trim() ;//"Sheet1"
    Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
    Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range(txtcol.Text.ToString().Trim(),txtrow.Text.ToString().Trim());//("A2", "A2")
    Label1.Text = excelCell.Value2.ToString();
    }
    catch (Exception ex)
    {
    Label1.Text = ex.ToString();
    }
     
    lahiruslk, Oct 31, 2006
    #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. Joachim Krais
    Replies:
    2
    Views:
    15,105
    Andre Beck
    Nov 23, 2003
  2. John Ramsden
    Replies:
    0
    Views:
    909
    John Ramsden
    Jul 24, 2004
  3. zher
    Replies:
    2
    Views:
    8,999
  4. hugh jass
    Replies:
    3
    Views:
    1,055
    Helen
    Sep 11, 2003
  5. KiwiBrian
    Replies:
    4
    Views:
    1,434
Loading...

Share This Page