views:

145

answers:

5

How Can I open and read all data in excel file to perform some operations on say write them to a database ...

+1  A: 

You can use the default library that comes with the .NET framework in order to use the Excel.Application Object and therefore the Workbook and Worksheets objects, so you can access Excel files, read or manipulate them

You can add it to your project by using the Add Reference option, the library is called

Microsoft.Office.Interop.Excel

Hope this helps

jgemedina
+1  A: 

Assuming that the Excel files are in a table format, I'd suggest that the best way would be using OleDB. This page has a very basic sample that should show you how to get started.

If you're unable to use OleDB for some reason, then you could use Excel Automation. This is not recommended if it's on a server though and will in general be slower and less stable than OleDB, but you will be able to do pretty much anything you need.

ho1
+1  A: 

You can automate Excel using com automation http://support.microsoft.com/kb/302096 , but if you are on a web server you will need to use a third party library like http://sourceforge.net/projects/koogra/

Geoff
+1  A: 

There are several ways:

  • If *.xslx (the new XML based format) is used, you can open that file and read the XML File
  • You can read it with Excel COM Interop (not recomended on a Server!)
  • You can use a ODBC Data Source
Arthur
A: 

Starting with Office 2007, you can use OpenXML to query/manipulate office documents. The .xlsx files (all Office .???x files) are zipped up XML files.

Edward Leno