모든 셀이 채워지면 Excel 워크 시트를로드해도 문제가 없습니다.! = null을 확인한 경우에도 Excel.Range가 null을 throw합니다.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : Laufzeitbindung kann의 대 덧글 NULL-Verweis nicht의 ausgeführt의 werden 다이 하지만 (즉 미안의 독일어) 나는 예외가 빈 셀입니다.
BEI CallSite.Target (폐쇄, CallSite, Object)를
확인, 아무 문제 없을 것, 내가 생각, 그래서 경우는 null 내가 셀 값을 확인하십시오
for (row = 2; row <= range.Rows.Count; row++) // Start at Row 2 to Ignore Headrow
{
DataRow dr = dt.NewRow();
for (column = 1; column <= range.Columns.Count; column++)
{
try
{
if(((Excel.Range)range.Cells[row, column]).Value2.ToString() != null)
{
dr[column - 1] = ((Excel.Range)range.Cells[row, column]).Value2.ToString();
}
}
catch (Exception e)
{
Console.WriteLine("Error " + column.ToString()); //Always Error when Cell is empty
Console.WriteLine(e);
}
}
sendConsole("Accept Row " + row + " of " + range.Rows.Count);
dt.Rows.Add(dr);
dt.AcceptChanges();
}
하지만 난 여전히 얻을 null 검사를위한 "Microsoft.CSharp.RuntimeBinder.RuntimeBinderException".
ToString()을 호출하기 전에 null을 확인해야합니다. 속성에 액세스하거나 null의 메서드를 호출 할 수 없습니다. – Crowcoder
와우! 나는 내 문제가 "멍청한 놈"문제가 아니라고 생각했다. 대단히 감사합니다 !!! –