江湖告急:asp.net服务器端关闭EXCEKL进程问题!(参照多个帖子方法,仍不能解决,请大虾帮忙)
环境:WIN2003SERVER ASP.NET OFFICE2003 VB.NET2005
网络用户具用变更和写入文件权限
代码如下:
Private Sub psWriteToExcel(ByVal dtdata As DataTable)
Dim strPath As String
Dim strFileName As String
Dim objFile As Scripting.FileSystemObject
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim i As Integer
Try
strPath = Me.Server.MapPath( ".. ") & "\XlsModule\ "
strPathName = Dir(strPath, vbDirectory)
If strPathName = " " Then
MkDir(strPath)
End If
objFile = New Scripting.FileSystemObject
xlApp = CreateObject( "Excel.Application ")
xlBook = xlApp.Workbooks.Add
xlSheet = xlBook.Worksheets(1)
'EXCEL操作(略)
xlBook.SaveAs(strPath & strFileName)
xlBook.Close()
xlApp.Workbooks.Close()
xlApp.Quit()
ReleaseComObject(xlSheet)