![](/img/trans.png)
[英]Microsoft Excel cannot access the file “…”. There are several possible reasons Windows Server 2008 R2 with Microsoft Office 2010
[英]Microsoft Office Excel cannot access the file on IIS
我有一个网络服务方法,它在给定的 Excel 文件中搜索字符串并返回其状态。 这在 VS 项目中工作正常。 但是当我在 IIS 中公开相同的 Web 服务时,它抛出错误:我在 Windows7 机器上工作
System.Runtime.InteropServices.COMException: Microsoft Office Excel cannot access the file 'C:\inetpub\wwwroot\MyFirstWebService\App_Data\Results.xlsx'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
string filePath = Server.MapPath("~") + @"\App_Data\Results.xlsx";
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(filePath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
我已经检查过filePath C:\\inetpub\\wwwroot\\MyFirstWebService\\App_Data\\Results.xlsx
并且没问题。
我也尝试过像下面这样的几个在线解决方案,但它还没有修复:
Create directory "C:\Windows\SysWOW64\config\systemprofile\Desktop " (for 64 bit Windows) or
"C:\Windows\System32\config\systemprofile\Desktop " (for 32 bit Windows)
Set Full control permissions for directory Desktop (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user
"IIS AppPool\DefaultAppPool")
为什么它在 VS 上而不是在 IIS 上工作? 我的用户帐户也获得了管理员权限,想知道为什么它不起作用。
谢谢
我在从 IIS 上托管的 MVC 应用程序读取 Excel 时遇到问题。 从 IIS 访问 Excel 有两件事很重要。
这有点奇怪,不知道为什么需要这样做,但对我有用。
我遇到了这个问题,在任何地方都找不到解决方案。 这里有多个问题。 IIS应用程序位于64位Windows Server 2008上,但Office的安装版本为32位版本。
本文为我指出了正确的方向:
但是,为了安全起见,我不得不将Dcom Config中Microsoft Excel应用程序的身份更改为管理员而不是启动用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.