can't remove Excel instance from memory using asp.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use Excel in asp.net to generate xls. After finish the file generation, I
use gc.collect to clear object used in the system. But I still found
EXCEL.EXE through the task manager. Please advise.
 
I use Excel in asp.net to generate xls. After finish the file generation,
I
use gc.collect to clear object used in the system. But I still found
EXCEL.EXE through the task manager. Please advise.

Are you calling the Quit() method after closing the file?
 
Already use objExcel.Quit(), but the instance still in memory.

OK. After calling the Quit() method, are you setting objExcel to null (or
Nothing, in VB.NET)?
 
I found that when I tried to access the worksheet object in the Excel like
the followings, then I call the ReleaseCOMObject and then using GC.collect,
the EXCEL.EXE still in memory. Is there anything I did wrongly? Pls advise.
Thx! :-)

oWorkSheet = oWorkBook.Sheets(nWorkSheet)
sWorkSheetName = oWorkSheet.Name()
TemplateDataView.RowFilter = "Template_Name='" & sWorkSheetName & "'"
..
..
..
oExcel.Quit()
oExcel = Nothing
NAR(oRange)
NAR(oWorkSheet)
NAR(oWorkBook)
NAR(oBooks)
NAR(oExcel)

GC.Collect()

Private Sub NAR(ByVal o As Object)
Try
ReleaseComObject(o)
Catch
Finally
o = Nothing
End Try
End Sub
 
Back
Top