I'm trying to use the code to find the address of a certain value in a Worksheet using Epplus and Linq. The value is in column D (4), but could be in any cell However, the following error is displayed
Linq Code
var query3 = (from cell in sheet.Cells["d:d"]
where cell.Value.ToString().Equals("CRÉDITOS")
select cell);
Error in Results 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()
No, it does not require Excel to be installed on the server, as you can read in the docs: EPPlus is a . NET library that reads and writes Excel files using the Office Open XML format (xlsx).
EPPlus is a very helpful open-source 3rd party DLL for writing data to excel. EPPlus supports multiple properties of spreadsheets like cell ranges, cell styling, charts, pictures, shapes, comments, tables, protection, encryption, pivot tables, data validation, conditional formatting, formula calculation, etc.
As @krillgar
suggested, you should rewrite the linq statement to include the possibility of Value
returning null
.
var query3 =
from cell in sheet.Cells["d:d"]
where cell.Value?.ToString() == "CRÉDITOS"
select cell;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With