Hi

Nowdays Iam developing application that use for read excel .So Once I run and close the application there are more than 5 excel.exe process are running.How to stop these process.Below I mention code which I used.

xlApp = new Excel.ApplicationClass();
             DataSet ds = new DataSet("DataSet"); xlWorkBook = xlApp.Workbooks.Open("C:\\Test.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            xlWorkSheet1 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);

Thanks
Tank50

Are you wanting simply to read the data out of the Excel worksheet like a database, or are you making a front-end spreadsheet wrapper?

If you want to automate Excel then you're taking the right approach, if you're wanting to read data like a database then I would have a different suggestion.

Hi
Thanks for reply.now it ok I got the coding that realase unwanted variables from memeory

if (xlWorkBook != null)
                    {

                        System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkBook); xlWorkBook = null;
                    }

                    // release the excel instance resources 

                    if (xlApp != null)
                    {

                        xlApp.Quit();
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);

                        xlApp = null;
                    }
Comments
thank you very much for sharing this beneficial information :)

Very nice solution and better a lot than one I gave, thank you very much for sharing this beneficial information :)

This article has been dead for over six months. Start a new discussion instead.