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

Recommended Answers

All 4 Replies

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.

Once you finish you can kill Excel process (IFF you don't need it anymore).

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;
                    }
commented: thank you very much for sharing this beneficial information :) +7

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.