Caution : If you did'nt terminate excel instances properly the server may slow down by accumulating the excel instances
oExcel.Quit();             
            
                try
                {
     
                    IntPtr pointer = new IntPtr(oExcel.Hwnd); // this will make sure that we are going to kill the same instance
                    oExcel.Visible = true;
                    foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcessesByName("Excel"))
                    {
                        if (proc.MainWindowHandle == pointer)
                            proc.Kill();
                    }
 
                }
                catch (Exception)
                {
                  
                }
oExcel is the object of your Excel App
 
 
Thanks You sebastian.. This helped me a lot !
ReplyDelete