G
Guest
Hi there,
I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the workbook. What I'm noticing is that once I'm done working with the workbook and have freed all the object references to the excel application, I still have an 'Excel' process running (when I look under 'Processes' in the Windows Task List).
Is there something I'm not cleaning up properly? Suggestions are greatly appreciated.
Here's what I'm doing:
Dim exApplication As Excel.Application
Dim exWorkBook As Excel.Workbook
Dim exWorkSheet As Excel.Worksheet
Try
exApplication = New Excel.Application
exWorkBook = exApplication.Workbooks.Open(fiSource.FullName)
exWorkSheet = exWorkBook.Worksheets(SHEET_NAME)
Dim iCount As Integer = 0
For r As Integer = 2 To MAX_CARDS
Dim strName As String = exWorkSheet.Cells(r, 1).value
If (strName Is Nothing) Then
Exit For
Else
.. do some stuff to the worksheet...
End If
Next
exWorkBook.Save()
Catch ex As Exception
MsgBox("There was an error accessing the Excel spreadsheet:" + vbCrLf + ex.ToString, MsgBoxStyle.Exclamation, Me.Text)
Finally
exWorkSheet = Nothing
exWorkBook = Nothing
exApplication.Quit()
exApplication = Nothing
End Try
I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the workbook. What I'm noticing is that once I'm done working with the workbook and have freed all the object references to the excel application, I still have an 'Excel' process running (when I look under 'Processes' in the Windows Task List).
Is there something I'm not cleaning up properly? Suggestions are greatly appreciated.
Here's what I'm doing:
Dim exApplication As Excel.Application
Dim exWorkBook As Excel.Workbook
Dim exWorkSheet As Excel.Worksheet
Try
exApplication = New Excel.Application
exWorkBook = exApplication.Workbooks.Open(fiSource.FullName)
exWorkSheet = exWorkBook.Worksheets(SHEET_NAME)
Dim iCount As Integer = 0
For r As Integer = 2 To MAX_CARDS
Dim strName As String = exWorkSheet.Cells(r, 1).value
If (strName Is Nothing) Then
Exit For
Else
.. do some stuff to the worksheet...
End If
Next
exWorkBook.Save()
Catch ex As Exception
MsgBox("There was an error accessing the Excel spreadsheet:" + vbCrLf + ex.ToString, MsgBoxStyle.Exclamation, Me.Text)
Finally
exWorkSheet = Nothing
exWorkBook = Nothing
exApplication.Quit()
exApplication = Nothing
End Try