UPDATE1:
I am using Excel 2010 and I’ve searched the web and found thousands upon thousands of ways to do this via win form, console, etc. But I can’t find a way to do this via DLL. and none of the sample on-line is complete all in bit and pieces.
UPDATE END
I have looked and goggled but did not get the specific what i am looking for, as show below the excel sample sheet.
i’m looking a way to read and store the each cell data in a variable
i have started something like this:
Workbook workbook = open(@"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);

Your code can work with a couple changes.
One thing to remember is that Excel worksheets are 1-based, not 0-based (and use Worksheet instead of IWorksheet):
And to get a range, it is easiest to call
get_Range()on the worksheet object (and use Range instead of IRange):With those two lines of code changed, your example will work fine.
UPDATE
Here is a “complete” example:
Reference”.
using Microsoft.Office.Interop.Excel;