1

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.

4

1 回答 1

3

Cell.Text应该工作,假设列I是第 9 列:

int count = worksheet.Cells[1, 9, worksheet.Dimension.End.Row, 9]
                     .Count(c => c.Text == "Value");

虽然它也应该与地址一起使用:

count = worksheet.Cells["i:i"].Count(c => c.Text == "Value");
于 2013-02-20T14:01:00.807 回答