Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Manipulating Excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo - 28 Sep 2007 20:33 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.