Reputation: 12896
I'm using EPPlus in a C# application for reading an Excel (.xlsx) file. What I need to do is counting how many cells in the column I
contain the value Value
.
For this I have defined the following query:
var query = (from worksheet.Cells["i:i"]
where cell.Value.ToString().Equals("Value")
select worksheet.Cells);
Howwever this does not seem to work. I'm pretty sure that the select
statement is wrong but I don't know what it should look like.
Upvotes: 1
Views: 3660
Reputation: 460108
Cell.Text
should work, assuming column I
is the 9th column:
int count = worksheet.Cells[1, 9, worksheet.Dimension.End.Row, 9]
.Count(c => c.Text == "Value");
although it should also work with the address:
count = worksheet.Cells["i:i"].Count(c => c.Text == "Value");
Upvotes: 3