Question

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?

Was it helpful?

Solution

I would suggest to export the excel table to CSV (Comma Seperated Values) format.

If possible, you could load the complete file and perform a search using Divide and Conquer

Basically, the idea behind it is to alphabetically sort the column that contains the value you are looking for, eg. we are looking for the name "peter" within the name column. Than, you take the value in the very middle of the column (eg. "malcom") and check if the value you are looking for comes before or after that middle value. In this case it should be AFTER "malcom" due to the sort, so you split the table in half and continue the search in the according half of the table. You can repeat that recursively until you have a hand full of records left in the table (lets say 10) and perform a regular search to find the value.

I once did such things in my final paper. My implementation was built in C++ and used hashtables. It was even faster than excel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top