Microsoft Office Excel中无法访问该文件'C:\\的Inetpub \\ wwwroot的\\时间表\\ App_Data文件\\ Template.xlsx“ [英] Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'

查看:1329
本文介绍了Microsoft Office Excel中无法访问该文件'C:\\的Inetpub \\ wwwroot的\\时间表\\ App_Data文件\\ Template.xlsx“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的code如下: -

I have my code as follows :-

Microsoft.Office.Interop.Excel.Application oXL = null;
Microsoft.Office.Interop.Excel.Sheets sheets;
Application excel = new Microsoft.Office.Interop.Excel.Application();


excel.Workbooks.Add(System.Reflection.Missing.Value);

/*
    * Here is the complete detail's about Workbook.Open()
    * 
    *  Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, 
    *  Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin,
    *  Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
    */

Workbook workbook = excel.Workbooks.Open(
    System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template.xlsx"),
    Missing.Value, true, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value,
    Missing.Value);
sheets = workbook.Worksheets;

现在的行: -

workbook = excel.Workbooks.Open(
    System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template.xlsx"),
    Missing.Value, true, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value,
    Missing.Value);

它得到从Visual Studio(F5)直接执行,但是当我尝试使用IIS访问它不会工作。
抛出的错误如下: -

It gets executed directly from the visual studio (F5) but when i try to access it with IIS it wont work. Throws error as follows:-

Microsoft Office Excel中无法访问该文件'C:\\的Inetpub \\ wwwroot的\\时间表\\ App_Data文件\\ Template.xlsx。有几种可能的原因:

  •文件名或路径不存在。

  •文件正被另一个程序。

  •您试图保存工作簿具有相同的名称为当前打开的工作簿。

Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.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.

我已经试过了工作围绕: -

I have tried the work around as:-


      
  • 文件夹和文件的存在,使访问IUSR _ ###(IIS用户)以及ASPNET用户所在的文件是文件夹中。

      
      

        
    • 在组件服务(DCOM)获准进入相应的用户。

    •   

    我已经给所有权限的到模板(.xlsx)格式存在

    I have already given all permission's to the folder where the template(.xlsx) exists

    任何建议??

    推荐答案

    试试这个:


    1. 创建的目录中的 C:\\ WINDOWS \\ Syswow64资料\\ CONFIG \\ systemprofile \\桌面的(对于64位Windows计算机上的Excel /办公室的32位版本)或 C: \\ WINDOWS \\ system32 \\设置\\ systemprofile \\桌面的(适用于办公室或32位版本的32位Windows计算机上的Office的64位Windows计算机上的64位版本)。

    2. 对于桌面的目录中,添加的完全控制的为相关用户(例如在Win7和放大器的权限,IIS 7和;对于用户的默认应用设置权限的 IIS程序池\\默认应用的)。

    1. Create the directory C:\Windows\SysWOW64\config\systemprofile\Desktop (for the 32-bit version of Excel/Office on a 64-bit Windows computer) or C:\Windows\System32\config\systemprofile\Desktop (for a 32-bit version of Office on a 32-bit Windows computer or a 64-bit version of Office on a 64-bit Windows computer).
    2. For the Desktop directory, add Full control permissions for the relevant user (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user IIS AppPool\DefaultAppPool).

    原帖与答案:

    • Excel 2007 automation on top of a Windows Server 2008 x64

    这篇关于Microsoft Office Excel中无法访问该文件'C:\\的Inetpub \\ wwwroot的\\时间表\\ App_Data文件\\ Template.xlsx“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆