我正在使用ASP.net(C#)編寫Web應用程序。我在服務器上有一個我想讀的excel文件。當我嘗試使用下面的代碼讀取這個excel文件時,它會拋出異常。我已經爲服務器上的用戶(IIS用戶)提供了完整的權限,用於保存excel文件的特定文件夾。使用C#讀取ASP.net中的excel文件時,訪問被拒絕
閱讀邏輯:
Excel.Application xlApp = null;
Excel.Workbook xlWorkbook = null;
Excel._Worksheet xlWorksheet = null;
Excel.Range range = null;
xlApp = new Excel.Application();
xlWorkbook = xlApp.Workbooks.Open("C:\inetpub\wwwroot\Uploads\data.xls);
xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(sheetName);
range = xlWorksheet.get_Range("A1", "B5");
例外:
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)).
能否請你幫我理解這個問題?