Problem Description: EXCEL Application named m_objexcel in an Aspx.cs, complete the M_Objexcel.quit () to turn off the Excel file after completing the data operation task of the open Excel file, but see the task manager still exists Excel process, occupying memory, checks some information, the final code is as follows, still unable to destroy the Excel process, you will see the problem there? {Object m_objOpt = System.Reflection.Missing.Value; Excel.Application m_objExcel = new Excel.ApplicationClass (); m_objExcel.Visible = true; Excel.Workbooks m_objBooks = (Excel.Workbooks) m_objExcel.Workbooks; Excel._Workbook m_objBook = ( Excel._Workbook) (m_objBooks.Open ((Server.MapPath ( "Printing.xls")), m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt)); Excel. Sheets m_objSheets = (Excel.Sheets) m_objBook.Worksheets; Excel._Worksheet m_objSheet = (Excel._Worksheet) (m_objSheets.get_Item (1)); Excel.Range m_objRange = m_objSheet.get_Range ( "B1", m_objOpt); m_objRange = m_objSheet .get_Range ( "B1", m_objOpt) .Value = 3; /// colse excel m_objBook.Save (); m_objBook.Close (false, m_objOpt, m_objOpt); m_objExcel.DisplayAlerts = false; m_objExcel.Quit (); System. Runtime.InteropServices.Marshal.ReleaseComObject (m_objRange); System.Runtime.InteropServices.Marshal.ReleaseComObject (m_objSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject (m _objSheets); System.Runtime.InteropServices.Marshal.ReleaseComObject (m_objBook); System.Runtime.InteropServices.Marshal.ReleaseComObject (m_objBooks); System.Runtime.InteropServices.Marshal.ReleaseComObject (m_objExcel); m_objRange = null; m_objSheet = null; m_objsheets = null; m_objbook = null; m_objBooks = null; m_objexcel = null; gc.collect ();} This problem has been plagued me for a long time. . There is also a problem. About C # operation Excel's top code is to operate on the server on the server on the web server and saved.
But I hope that it can open this Excel file in the client's browser like ASP, and then operate on this file. That is also visible, not the background. how should I do it? Although there is a row m_objexcel.visible = true in the code; however, whether the server is still open and operated on the client or on the client. Just in the server process, the permanent retains the death without dead. Solution 1: You can kill this process through the process ID. How do you do it: You can add this code in the end.
Process [] processes = system.diagnostics.Process.getProcesses ();
For (int i = 0; i { IF (processes [i] .processname.toString () == "Excel") { Processes [i] .Kill (); //Response.write(Processes[i].processname.tostring() "had been killed"); } //Response.write (" } Other solutions continue to study, if you have a good method, please tell me. Thank you
" processes [i] .processname.toT7tring () "
");