My question is basically just how to end the Excel.exe process that runs when using excel. In the application I open and use an excel workbook with a couple sheets, then lea
I know this is an old thread, but if anyone comes back to this, you actually have to call every Interop.Excel object you touch in the workbook. If you pull in an instantiated class from Excel into your code, when you're done with it, Marshal.ReleaseComObject. Even every cell. It's crazy, but it's the only way I was able to get the same issue resolved.
And make darn sure you don't have a fatal exception and leave something unreleased... Excel will stay open.
Excel.Applicaiton? Marshal.ReleaseComObject.
Excel.Workbook? Marshal.ReleaseComObject.
Excel.Workshet? Marshal.ReleaseComObject.
Excell.Range? Marshal.ReleaseComObject.
Looping through Rows? Marshal.ReleaseComObject every row and cell you loop through.
Exce.Style? Marshal.ReleaseComObject... At least this is what I had to do...
If you plan on using the PIA to access Excel, from the first line of code you write, plan how you're going to release your objects. The best approach I've had is to make sure that I pull an excel value out of the Excel object and load it into my own internal variable. Then imediately call Marshal.ReleaseComObject you accessed. Looping through excel objects via a list in a Application, Workbook, Sheet, ListObject, Table, etc, tends to be the hardest to release. Hence planning is rather critical.