I'm trying to parse text from an Excel doc in C#. The problem is that I can't find a way to detect (and ignore) blank cells.
I'm using Microsoft.Office.Interop.Excel in Visual Studio 2010 C#. I can't skip blank cells so my program will consequentially store blank values.
I have defined my woorksheet the following way:
Excel.Application exApp = OpenExcel(); String mySheet = @"C:\sheet.xlsx"; Excel.Workbook wb = exApp.Workbooks.Open(mySheet); Excel.Worksheet ws = wb.Sheets[1];
I access my cells by ws.Cells[row, col]
. And I've tried different approaches. To name a few:
ws.Cells[row, col].Value2 == null
ws.Cells[row, col].Value == null
ws.Cells[row, col].Value == ""
And also using the Range object explicitely
Excel.Range rng = ws.Cells[row, col]
To use rng.Value2
Depending on which approach I use I get different errors, Exception from HRESULT: 0x800A03EC is one of them.
null
to a string. – D Stanley Feb 10 '15 at 18:27