我正在尝试使用代码通过 Epplus 和 Linq 在工作表中查找特定值的地址。该值在 D (4) 列中,但可以在任何单元格中 但是,显示如下错误
链接代码
var query3 = (from cell in sheet.Cells["d:d"]
where cell.Value.ToString().Equals("CRÉDITOS")
select cell);
结果 View 中的错误:
at ExcelTests.Form1.<>c.<button1_Click>b__1_0(ExcelRangeBase cell)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
最佳答案
正如 @krillgar
所建议的,您应该重写 linq 语句以包括 Value
返回 null
的可能性。
var query3 =
from cell in sheet.Cells["d:d"]
where cell.Value?.ToString() == "CRÉDITOS"
select cell;
关于c# - 用 Epplus 寻找值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42539689/