EPPLUS如何使用find命令查找数据

我正在使用EPPLUS在C#.NET 4.0中编写一个应用程序,并尝试加载一个巨大的20mb excel文件。 我想使用Find或Findall方法在工作表中查找特定的string。 任何人都可以请分享如何做到这一点,因为在互联网上没有这方面的信息。

我想避免读取所有的细胞,因为它需要很多时间。 我想find特定的string,只是复制该特定的行而不读取整个表。

谢谢。

ExcelDataValidationCollection上的Find和FindAll方法不用于在工作簿/工作表中searchstring,而是使用lambdaexpression式在工作表中search特定的数据validation。

如果你想查询工作表的匹配值,Linq可能是最好的方法。 您可以在查询中指定一个范围,这样您就不必遍历整个工作表。 本示例来自EPPlus示例中的示例8,可以在codeplex上进行下载。

//Here we use more than one column in the where clause. We start by searching column D, then use the Offset method to check the value of column C. var query3 = (from cell in sheet.Cells["d:d"] where cell.Value is double && (double)cell.Value >= 9500 && (double)cell.Value <= 10000 && cell.Offset(0, -1).GetValue<DateTime>().Year == DateTime.Today.Year+1 select cell); Console.WriteLine(); Console.WriteLine("Print all cells with a value between 9500 and 10000 in column D and the year of Column C is {0} ...", DateTime.Today.Year + 1); Console.WriteLine(); count = 0; foreach (var cell in query3) //The cells returned here will all be in column D, since that is the address in the indexer. Use the Offset method to print any other cells from the same row. { Console.WriteLine("Cell {0} has value {1:N0} Date is {2:d}", cell.Address, cell.Value, cell.Offset(0, -1).GetValue<DateTime>()); count++; }