Excel automation memory leak

G

Guest

I'm building a reporting system in asp.net which needs an "export to Excel" function. We have Excel 2000 in the office. So I've added a reference to the Microsoft Excel 9.0 Object Library.

Having added "<identity impersonate='true'/>" to my Web.config, I can now create an instance of Excel and manipulate it, more or less as described in KB#306023 ( http://support.microsoft.com/default.aspx?scid=kb;EN-US;306023 ).

However, each time I do this, I end up with another EXCEL.EXE process staying active. I can't even manually end them (I get an "Unable to terminate process" "Access denied" error).

The core lines look like this:
Excel.Application xl = new Excel.Application();
Excel.Workbooks xwbs = xl.Workbooks;
Excel.Workbook xwb = xwbs.Add( Missing.Value );
Excel.Sheets xwss = xwb.Worksheets;
Excel.Worksheet xws = (Excel.Worksheet)xwss.get_Item( 1 );
Excel.Range xr1 = xws.get_Range( "A1", Missing.Value );
xr1.Value = "Hello world!";
xwb.SaveAs( @"C:\helloworld.xls", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value );
xwb.Close( false, Missing.Value, Missing.Value );
xl.Quit();

The Quit() method doesn't seem to have any effect.

What do I need to do to stop these processes?

Any help will be greatly appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top