Reputation: 5523
How Can I open and read all data in excel file to perform some operations on say write them to a database ...
Upvotes: 1
Views: 966
Reputation: 1492
ExcelToEnumerable is a great solution if you want to map Excel data to a list of classes, e.g:
var filePath = "/Path/To/ExcelFile.xlsx";
IEnumerable<MyClass> myClasses = filePath.ExcelToEnumerable<MyClass>();
Disclaimer. I am the author of ExcelToEnumerable.
Upvotes: 0
Reputation: 6327
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.
Upvotes: 0
Reputation: 8129
There are several ways:
Upvotes: 1
Reputation: 4746
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/
Upvotes: 1
Reputation: 55049
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.
Upvotes: 1
Reputation: 526
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
Upvotes: 1