16,554
社区成员
发帖
与我相关
我的任务
分享
Public Sub OutExcFile(ByVal strUserId As String, ByVal objControl As System.Web.UI.Control)
Dim objExcel As Excel.Application
Dim objWorkBooks As Excel.Workbooks = Nothing
Dim objBook As Excel.Workbook = Nothing
Dim objSheets As Excel.Sheets = Nothing
Dim objWorkSheet As Excel.Worksheet = Nothing
objExcel = New Excel.Application
Try
逻辑处理。。。
Catch ex As Exception
Throw ex
Finally
If Not IsNothing(objWorkSheet) Then
ReleaseComObject(objWorkSheet)
End If
If Not IsNothing(objBook) Then
ReleaseComObject(objBook)
End If
If Not IsNothing(objSheets) Then
ReleaseComObject(objSheets)
End If
If Not IsNothing(objWorkBooks) Then
ReleaseComObject(objWorkBooks)
End If
If objExcel IsNot Nothing Then
objExcel.UserControl = False
'Excel退出
objExcel.Quit()
'对像释放
ReleaseComObject(objExcel)
Dim intgeneration As Integer = 0
intgeneration = System.GC.GetGeneration(objExcel)
objExcel = Nothing
System.GC.Collect(intgeneration)
System.GC.Collect()
End If
End Try
End Sub