我尝试在 Asp.Net 中读取一个 excel 文件。我有这个错误:
Microsoft Excel cannot access the file 'C:\tablobilgisayar.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.
我的代码是:
Microsoft.Office.Interop.Excel.Application ExcelObj = null;
ExcelObj = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(
@"C:\tablobilgisayar.xlsx", 0, true, 5,
"", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
我的磁盘上有这个文件,路径是真的。我也使用 IIS 7.5。我认为这是关于 IIS 的。因为我将粘贴文件复制到另一个使用 Visual Studio 的本地 IIS 的空 asp.net 项目中,并且它有效。
有人对此有想法吗?谢谢。