S
Shirin14
Guest
I am using an excel sheet as an input for my code, i.e I am taking data row by row from each column in excel and assigning it to property of a class
case 1 : It gets assigned easily , if there is value in a column .
Case 2 : it doesnt works and throws an error for the columns which are empty
The error is: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Cannot perform runtime binding on a null reference'
Here is what I have done:
className.propertyName= (string)(xlRange.Cells[rowABCD, 2] as Range).Value2.ToString();
also I have tried:
className.propertyName = className.propertyName == null ? className.propertyName= (string)(xlRange.Cells[rowABCD, 7] as Range).Value2.ToString() : className.propertyName = " Empty";
Continue reading...
case 1 : It gets assigned easily , if there is value in a column .
Case 2 : it doesnt works and throws an error for the columns which are empty
The error is: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Cannot perform runtime binding on a null reference'
Here is what I have done:
className.propertyName= (string)(xlRange.Cells[rowABCD, 2] as Range).Value2.ToString();
also I have tried:
className.propertyName = className.propertyName == null ? className.propertyName= (string)(xlRange.Cells[rowABCD, 7] as Range).Value2.ToString() : className.propertyName = " Empty";
Continue reading...