I don't know what is wrong but Excel.exe remains in the task list even after I have entered this source code:
ExcelWorkBook.SaveAs(Directory.GetCurrentDirectory() + "\\deleteme.xls", misValue, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlNoChange, misValue, misValue, misValue, misValue);
ExcelWorkBook.Close(null, null, null);
ExcelApplication.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkBooks);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkSheet);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkBook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApplication);
GC.Collect();
GC.WaitForPendingFinalizers();
I cannot seem to close Excel in C#. Any help would be greatly appreciate it! Thanks in advance.
Loading
Fahed Al DayePosted Jul 30, 2010, 7:49 PM
Roy SPosted Jul 30, 2010, 4:16 PM
It's also a lot faster and doesn't require excel to be installed.
Fahed Al DayePosted Jul 30, 2010, 2:03 PM
Mahesh ChandPosted Jul 30, 2010, 10:25 AM
srinivasPosted Jul 30, 2010, 8:38 AM
before GC.Collect();
you have to make all the Excel Application objects to null.
ExcelWorkBooks=null;
ExcelWorkSheet=null;
ExcelWorkBook=null;
ExcelApplication=null;
GC.Collect();
I hope it helps you ,If yes then mark as Accepted Answer
Thank you
Fahed Al DayePosted Jul 29, 2010, 6:39 PM
JoePosted Jul 29, 2010, 6:38 PM