How do I access the string value in a cell in an Excel worksheet?
string cellInfo = (string)w.Cells[3, 3];
I want the string value in the 3rd row, 3rd column, C3
Excel.Application excel = new Excel.Application();
Excel.Workbook workBook = excel.Workbooks.Open(string.Format(@"{0}\{1}", Directory.GetCurrentDirectory(), excelFilename),
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
List<Excel.Worksheet> result = excel.Worksheets.Cast<Excel.Worksheet>().Where(w => !exclude.Contains(w.Name)).ToList();
result.ForEach(w => {
Excel.Range objRange = w.get_Range("C3", "C3");
string colLengthStr = objRange.Value2;
}
There are many answers on SO about how to get data from Excel using c#. But you will need to do something similar to this:
How to read data of an Excel file using C#?
Resources for learning c# Excel interop
Or
C# Excel Interop
Or Even
How to automate Excel from C#.NET
Code from the automate Excel from c#.net, which includes reading/writing to cells:
Based on your edit try the following: