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.
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(excelCel l2.Cells.V alue2.ToSt ring()); //Print the value of the cell for a single cell selection
becomes something like:
double val = (double)excelCell2.Cells.V alue2
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(excelCel
becomes something like:
double val = (double)excelCell2.Cells.V
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.
I used this quite often.
Have a look:
http://www.codeproject.com/KB/dotnet/ExportExcelData.aspx
Quite many links of this sort.
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and
http://support.microsoft.com/kb/302084
should get you started