Search code examples
c#.netexcelms-officeoffice-interop

Fastest way to enumerate or look for all empty Excel cells and change their style or do some other processing


Which would be potentially a best way to enumerate or iterate or simply look for empty cells or cells with specific data structure in Excel, and later once you find it do some processing on it.

I tired Range, Value, Value2, etc but it takes fairly long time when Excel Sheet is considerably larger. I believe there must be some other efficient way. It would be nice, if you can show some example snippet.


Solution

  • The answer is relativley simple: get the array in one batch from excel (search SO for a how to) - test the values of the erray for empty cells and then acess only the empty cells in excel.

    It is somewhat cumbersome, but the fastes way because iterating each cell is vastly slower than simply getting all data in a batch.