0

我正在尝试将此代码作为 SharePoint 解决方案运行。当我部署它时,它在尝试打开 excel 文件时卡住了:很可能,解决方案没有访问权限。当我尝试在控制台应用程序中运行相同的代码时,打开工作簿时,控制台应用程序会询问用户名和密码。

string fileName = "http://spserver/sites/dev2/Style%20Library/BookRefresh.xlsx";
var excel = new Microsoft.Office.Interop.Excel.Application();
excel.DisplayAlerts = false;
Workbook theWorkbook = excel.Workbooks.Open(fileName);

拜托,您知道如何获得在共享点解决方案中访问此文件的权限吗?谢谢你

这是错误:

System.Runtime.InteropServices.COMException was unhandled by user code
  HelpLink=xlmain11.chm
  HResult=-2146827284
  Message=Microsoft Excel cannot access the file 'http://spserver/sites/dev2/Style Library/BookRefresh.xlsx'. There are several possible reasons:

• 文件名或路径不存在。• 该文件正被另一个程序使用。• 您尝试保存的工作簿与当前打开的工作簿同名。

4

0 回答 0