I've created a function in my Vb.Net application where I allow the user to export DataGridView data to Excel. What happens is I save the file, then ask the user if they want to view it. If they chose yes then I open excel and display the data to them like this...
If x = vbYes Then
Process.Start("Excel.exe", filename)
End If
xlWorkBook.Close()
xlApp.Quit()
releaseobject(xlApp)
releaseobject(xlWorkBook)
releaseobject(xlWorkSheet)
and
Private Sub releaseobject(ByVal obj As Object)
Try
system.runtime.interopservices.marshal.releasecomobject(obj)
obj = Nothing
Catch ex As exception
obj = Nothing
Finally
gc.collect()
End Try
End Sub
This looks like it should take care of instance of Excel running in the background. I've tested it multiple times. The data opens fine, everything is okay, then I close it. Each time after I run this function I still see Excel runnign in the processes. Any Ideas?
If need be, i can display my other code...lmk