Link to home
Start Free TrialLog in
Avatar of abemiester
abemiester

asked on

Best way to parse a Excel spreadsheet with C#?

I've been using Microsoft.Jet.OLEDB.4.0 to parse spreadsheets for a while with no problems but i recently ran into an issue that will no longer allow me to use this method.  What is the best way to parse an Excel (NOT a csv) using .NET?  I am using Visual Studio 2008.
Avatar of ShannonE
ShannonE

1 thing to note:
In the 1st link they only mention retrieving a String value from one of the cells.  If it's a number you want, you'll need to cast value2, so

Console.WriteLine(excelCell2.Cells.Value2.ToString()); //Print the value of the cell for a single cell selection

becomes something like:

double val = (double)excelCell2.Cells.Value2
If you have tables in Excel and need to work with the data probably the best way is to load the data into a dataset.
I used this quite often.

Have a look:
http://www.codeproject.com/KB/dotnet/ExportExcelData.aspx

Quite many links of this sort.
Avatar of abemiester

ASKER

Hey Shannon,
I tried that first link but VS is unable to find Excel.ApplicationClass().  Have you successfully tried this your self?  If so which version of the COM assembly for Excel did you include?
ASKER CERTIFIED SOLUTION
Avatar of ShannonE
ShannonE

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial