0

I need to write an application in C# (VS 2008) that will search in a relatively large (80K rows) excel file for a specific row. I would normally use ADO.net, but Windows Mobile doesn't support this. I've tried to export excel into xml and parse it with linq, but it is still slow. Does anyone have any suggestions?

4

1 回答 1

2

我建议将 excel 表导出为 CSV(逗号分隔值)格式。

如果可能,您可以加载完整的文件并使用分而治之进行搜索

基本上,它背后的想法是按字母顺序对包含您要查找的值的列进行排序,例如。我们正在名称列中查找名称“peter”。然后,您获取列中间的值(例如“malcom”)并检查您要查找的值是在该中间值之前还是之后。在这种情况下,由于排序,它应该在“malcom”之后,因此您将表分成两半并继续在表的相应一半中进行搜索。您可以递归地重复该操作,直到您在表中留下满满一手的记录(比如说 10 条),然后执行常规搜索以找到该值。

我曾经在我的期末论文中做过这样的事情。我的实现是用 C++ 构建的,并使用了哈希表。它甚至比excel还要快。

于 2013-06-27T06:50:28.320 回答