我想读一个.xls
文件是从第三方网站下载。我不会每天处理文件,所以在上传文件之前我无法将格式更改为.xlsx
。 Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
与CLSID {00024500-0000-0000-C000-000000000046}检索COM类工厂组件失败
我使用的是vb.net
本站IIS7
:
我不断收到以下错误。 应用程序池用我的用户登录,我的用户是服务器上的管理员,可以访问所有内容。
我也做了以下内容:
- 办公室安装在主机
- 我已经进入
DCOMCNFG
并提出确保Launch and Activation Permissions
,Access Permissions
和Configuration Permissions
拥有完全控制我的登录帐户上。 - 服务器具有x64体系结构,而且我也有Office 64安装
- 我已确认该文件夹
C:\Windows\SysWOW64\config\systemprofile\Desktop
以及C:\Windows\SysWOW64\config\systemprofile\Desktop
确实存在。 - 我知道
C:\Windows\SysWOW64\config\systemprofile\Desktop
适用于x86架构,但我确定它是在那里以防万一系统想要使用它。
这是我的代码如下所示:
Imports genlib
Imports Excel = Microsoft.Office.Interop.Excel
Partial Class HeadOffice_OpperationalParameters_FailedBranches
Inherits System.Web.UI.Page
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
Protected Sub btnRunReport_Click(sender As Object, e As EventArgs) Handles btnRunReport.Click
If fuReport.HasFile = False Then
ClientScript.RegisterClientScriptBlock(Me.GetType, "", "alert('Upload a file to process.');", True)
Exit Sub
End If
Dim ReportFileName As String = Server.MapPath("~") & "FilesUploaded\" & fuReport.FileName.Replace(".XLS", "_" & Today.ToString("yyyy.MM.dd") & "_" & TimeOfDay.ToString("HH.mm.ss") & ".xls")
fuReport.SaveAs(ReportFileName)
Dim xlApp As Excel.Application 'Here
Dim xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
Try
'=================================================
' ERROR OCCURS ON NEXT LINE
'=================================================
xlApp = New Excel.ApplicationClass
xlWorkbook = xlApp.Workbooks.Open(ReportFileName)
xlWorksheet = xlWorkbook.Worksheets("RptTransactionDetail")
BrowserWrite(xlWorksheet.Cells(2, 2).value, True)
xlWorkbook.Close()
xlApp.Quit()
Catch ex As Exception
ClientScript.RegisterClientScriptBlock(Me.GetType, "", "alert('" & ex.Message.Replace("'", "\'").Replace(vbCr, "\r").Replace(vbLf, "\n") & "');", True)
Exit Sub
End Try
releaseObject(xlApp)
releaseObject(xlWorkbook)
releaseObject(xlWorksheet)
End Sub
End Class
谁能告诉我如何解决这个错误,或采取什么步骤,以确定问题?
我已经阅读了堆栈溢出的大部分帖子,但是有太多无法添加我已经看过的每个答案。
错误发生在哪条线上? – dbasnett
@dbasnett第33行:xlApp =新Excel.ApplicationClass –
你试过xlApp =新的Excel。应用程序 – dbasnett