Reputation: 263
If one has a reference to a cell, how does one check if it is null?
Pseudo Code:
Excel.Range cell = (Excel.Range)MyRange.Cells[1, 1];
if (cell.value2.IsNull) { Stuff }
else { Other Stuff }
Unfortunately, IsNull
does not exist.
Upvotes: 3
Views: 14349
Reputation: 1
if (mWSheet1.Cells[z, y + 3].Value2 != null)
or
orderPc.ManufactureDate = Convert.ToString(mWSheet1.Cells[z, y + 3].Value2);
Upvotes: -1
Reputation: 6455
You were overthinking. Range.Value2
returns an object. So if you'd like to check for null reference, just do
if(Range.Value2 == null)
{
//blah blah
}
else
{
//blah blah
}
You probably should check out the online API documentation a bit more.
http://msdn.microsoft.com/en-us/library/ms262200(v=office.14).aspx
Upvotes: 9