What's the way to open a excel workbook and to read excel cells?
Use Visual Studio Tools for Office (VSTO) to extend Office products with your code and here's a good tutorial to get you started in Excel programming
SpreadsheetGear for .NET will do it. Here is a simple example:
using System;
using SpreadsheetGear;
namespace Program
{
internal class test
{
internal test()
{
Factory.GetWorkbook();
}
}
class Program
{
static void Main(string[] args)
{
IWorkbook workbook = Factory.GetWorkbook(@"C:\tmp\MyWorkbook.xls");
IWorksheet worksheet = workbook.Worksheets[0];
IRange a1 = worksheet.Cells["A1"];
object rawValue = a1.Value;
string formattedText = a1.Text;
Console.WriteLine("rawValue={0} formattedText={1}", rawValue, formattedText);
}
}
}
You can see live ASP.NET samples here or download the free trial here if you want to try it yourself.
Disclaimer: I own SpreadsheetGear LLC
You can also use open xml sdk to read (and write) excel files (in open xml format off course). There is an msdn article describing how to use the open xml sdk.
A big advantage is that you don't have to install excel on the server (or client) to read excel files.
SmartXLS for .Net can read/write Excel files in both xls and xlsx format.It is a commercial Excel spreadsheet component and support most Excel features.