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!
Mark Rae [MVP] - 28 Sep 2007 21:35 GMT
> 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

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
sloan - 28 Sep 2007 21:56 GMT
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.
> using Excel;
>
[quoted text clipped - 14 lines]
>
> Thanks!