I am working with Excel Interop in C# and am writing code to do somewhat complicated manipulation of tables with tens of thousands of rows of data. It tends to run pretty slow.
I often have data stored in some kind of variables that I perform some intermediate calculations on before ultimately writing the results to a worksheet.
I am sure this is not a good approach, but I frequently find myself building a temporary worksheet that will be deleted when my code is finished executing, so that I can use Excel methods of the Range property on the data rather than trying to implement similar methods in an array. Most frequently, this involves things like sorting by multiple columns, removing duplicates, etc. These columns almost always have many different types of data (strings, whole numbers, numbers with two decimal places - although the actual data types stored in these cells does not seem to always be straightforward (100000000.01 for example seems to sometimes be of type double and other times be decimal). The easiest way to deal with all of the different data types seems to be just using an Excel range, and this is why my code is frequently creating temporary worksheets, then deleting them in my code.
What is the proper, efficient way to deal with these types of situations?