Manipulating Excel

Discussion in 'ASP .Net' started by Paulo, Sep 28, 2007.

  1. Paulo

    Paulo Guest

    using Excel;

    Excel.Application ExcelApp = new Excel.ApplicationClass();
    string workbookPath = Server.MapPath("excel\\produto1.xls");
    Excel.Workbook excelWorkbook = ExcelApp.Workbooks.Open(workbookPath,
    0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
    true, false, 0, true, false, false);
    string currentSheet = "Plan1";
    Excel.Sheets excelSheets = excelWorkbook.Worksheets;
    Excel.Worksheet excelWorksheet =
    (Excel.Worksheet)excelSheets.get_Item(currentSheet);


    Im using the code above, but how can I loop through all the columns and rows
    of the sheet? Can you help me?

    Using VS 2005 asp.net 2.0 C#

    Thanks!
     
    Paulo, Sep 28, 2007
    #1
    1. Advertising

  2. "Paulo" <> wrote in message
    news:...

    > Excel.Application ExcelApp = new Excel.ApplicationClass();


    > Im using the code above, but how can I loop through all the columns and
    > rows of the sheet?


    You can't.

    Excel, like the rest of Office, is not designed to run via server-side
    Office automation - Microsoft won't support any solution which even attempts
    this, because it doesn't work:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

    To meet your requirements, you need this:
    http://www.aspose.com/Products/Aspose.Cells/Default.aspx


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Sep 28, 2007
    #2
    1. Advertising

  3. Paulo

    sloan Guest

    You can use a System.Data.OleDb.OleDbConnection and get an IDataReader
    against the Excel spreadsheet.
    http://support.microsoft.com/kb/316934


    It would be best to avoid the excel object model, and as pointed out
    already, is a really bad idea server side.






    "Paulo" <> wrote in message
    news:...
    > using Excel;
    >
    > Excel.Application ExcelApp = new Excel.ApplicationClass();
    > string workbookPath = Server.MapPath("excel\\produto1.xls");
    > Excel.Workbook excelWorkbook = ExcelApp.Workbooks.Open(workbookPath,
    > 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
    > true, false, 0, true, false, false);
    > string currentSheet = "Plan1";
    > Excel.Sheets excelSheets = excelWorkbook.Worksheets;
    > Excel.Worksheet excelWorksheet =
    > (Excel.Worksheet)excelSheets.get_Item(currentSheet);
    >
    >
    > Im using the code above, but how can I loop through all the columns and
    > rows of the sheet? Can you help me?
    >
    > Using VS 2005 asp.net 2.0 C#
    >
    > Thanks!
    >
     
    sloan, Sep 28, 2007
    #3
    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. Kelvin Tsai @ Singapore

    Manipulating with the T1, T0 and TX in a SAIF file.

    Kelvin Tsai @ Singapore, Sep 9, 2003, in forum: VHDL
    Replies:
    0
    Views:
    727
    Kelvin Tsai @ Singapore
    Sep 9, 2003
  2. Tom Rowton
    Replies:
    2
    Views:
    684
    Tom Rowton
    Aug 1, 2003
  3. =?Utf-8?B?Smlt?=

    Manipulating Excel data with ASP.NET

    =?Utf-8?B?Smlt?=, Nov 2, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    6,824
    =?Utf-8?B?Smlt?=
    Nov 3, 2005
  4. spirit
    Replies:
    4
    Views:
    565
    spirit
    Aug 3, 2007
  5. =?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,575
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
Loading...

Share This Page