五千年(敝帚自珍)

主题:【求助】VB.Net高手们进来瞅一瞅啦, CR问题 -- MacArthur

共:💬24 🌺14
全看分页树展 · 主题 跟帖
家园 see the text in red

Sub generateCryatalReport(ByVal strReportName As String)

Dim datatable As System.Data.DataTable = dsWKIT.Tables(0)

Dim Application As New Excel.Application()

Application.SheetsInNewWorkbook = 1

Dim wb As Excel.Workbook = Application.Workbooks.Add()

Dim ws As Excel.Worksheet = wb.Worksheets("Sheet1")

ws.Name = strReportName

Dim rowIndex As Integer

Dim colIndex As Integer

Try

...

Catch ex As System.Runtime.InteropServices.COMException

finally

wb.SaveAs("C:\" & strReportName & ".xls")

wb.Close()

Application.Quit()

if not wb is nothing then marshal.releasecomobject(wb)

if not ws is nothing then marshal.releasecomobject(ws)

if not application is nothing then marshal.releasecomobject(application)

wb=nothing:ws=nothing:application=nothing

gc.collect()

End Try

End Sub

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河