Hey all,
Is there any body in the world who can tell me why Excel is not quiting (still in task manager)
part of my code is:
public class Webform1
Public Shared xlApp As New Excel.Application
Public Shared xlBooks As Excel.Workbooks
Public Shared xlBook As Excel.Workbook
Public Shared xlSheet As Excel.Worksheet
function buttonGenerateFile
xlBooks = xlApp.Workbooks
xlBook = xlBooks.Add
xlBook.SaveAs(ExcelFileName)
xlSheet = xlBook.Worksheets(1)
...... fill data in excel file
try System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
xlSheet = Nothing
xlBook.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
xlBook = Nothing
xlBooks.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks)
xlBooks = Nothing
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
Catch
End Try
Catch exception As Exception
MsgLabel.Text = exception.ToString()
Finally
' Invoke garbage collector before termination
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
End Try
thanks in advance,
wim
Is there any body in the world who can tell me why Excel is not quiting (still in task manager)
part of my code is:
public class Webform1
Public Shared xlApp As New Excel.Application
Public Shared xlBooks As Excel.Workbooks
Public Shared xlBook As Excel.Workbook
Public Shared xlSheet As Excel.Worksheet
function buttonGenerateFile
xlBooks = xlApp.Workbooks
xlBook = xlBooks.Add
xlBook.SaveAs(ExcelFileName)
xlSheet = xlBook.Worksheets(1)
...... fill data in excel file
try System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
xlSheet = Nothing
xlBook.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
xlBook = Nothing
xlBooks.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks)
xlBooks = Nothing
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
Catch
End Try
Catch exception As Exception
MsgLabel.Text = exception.ToString()
Finally
' Invoke garbage collector before termination
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
End Try
thanks in advance,
wim