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

C# EPPLUS如何使用find命令查找数据,c#,excel,epplus,C#,Excel,Epplus,我正在使用EPPLUS在C.NET4.0中编写一个应用程序,并尝试加载一个巨大的20mb excel文件。我想使用find或Findall方法在工作表中查找特定字符串。任何人都可以分享一段如何做到这一点,因为互联网上没有关于这一点的信息 我想避免读取所有单元格,因为这需要很多时间。我想找到那个特定的字符串,只复制那个特定的行,而不读取整个工作表 谢谢。ExcelDataValidationCollection上的Find和FindAll方法不用于搜索工作簿/工作表中的字符串,而是允许您使用lam

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

我想避免读取所有单元格,因为这需要很多时间。我想找到那个特定的字符串,只复制那个特定的行,而不读取整个工作表


谢谢。

ExcelDataValidationCollection上的Find和FindAll方法不用于搜索工作簿/工作表中的字符串,而是允许您使用lambda表达式在工作表中搜索特定的数据验证

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

//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++;
            }

ExcelDataValidationCollection上的Find和FindAll方法不用于搜索工作簿/工作表中的字符串,而是允许您使用lambda表达式在工作表中搜索特定的数据验证

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

//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++;
            }

你试过什么?Find/FindAll方法在哪里?我看不到它们..它在数据验证类中。我使用了一个简单的for循环来完成我的工作。你尝试了什么?Find/FindAll方法在哪里?我看不到它们..它在数据验证类中。我使用了一个简单的for循环来完成我的工作。我在ExcelCellDeleteList{var query3=from ws.Cells[b:b]中的单元格中执行下面的foreach字符串cellString时遇到了一个问题,其中cell.Value是string select cell;}我想搜索cellString字符串。我在ExcelCellDeleteList{var query3=from ws.Cells[b:b]中的单元格中执行以下foreach字符串cellString时遇到问题,其中cell.Value是string select cell;}我想搜索cellString字符串。