Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'

前端 未结 7 1540
死守一世寂寞
死守一世寂寞 2020-11-27 12:35

I have my code as follows :-

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


        
相关标签:
7条回答
  • 2020-11-27 13:16

    Let me note that in my place, adding the c:\windows\syswow64\config\systemprofile\desktop directory didn't work.

    The point is that WOW64 stands for Windows on Windows64, that means it actually applies for 32-bit programs running on the 64bit OS.

    Since I have 64-bit Excel installed, the proper directory turned out to be the c:\windows\system32\config\systemprofile\desktop

    0 讨论(0)
  • 2020-11-27 13:20

    I was previously attempt this problem then i resolved.

    Solution:

    I put the full permission to particular folder(Sub folder and files) and checked working fine.

    0 讨论(0)
  • 2020-11-27 13:28

    This works

    excel.exe /safe

    This does not and gives the same error as the regular excel startup

    excel.exe /automation

    This also occurs for all MS Office 2007 apps for ANY network file. Local file access is fine.

    0 讨论(0)
  • 2020-11-27 13:32

    I've wrapped my WCF in a Windows Service. Creating the Desktop Folders did solve it for me on one machine, but not on another.

    My problem in the end was, that my Windows Service did not run under an active User of the machine. Configuring the service to run under a user which is active on the machine solved this problem for me so far.

    Only the combination of

    • Existing Desktop Folder
    • Service running under a real user Account

    got it working for me.

    This article lead me to the full solution: Cannot access excel file

    0 讨论(0)
  • 2020-11-27 13:33

    Try this:

    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).

    1. 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).

    Original post with answer:

    • Excel 2007 automation on top of a Windows Server 2008 x64
    0 讨论(0)
  • 2020-11-27 13:36

    In my case, I followed the suggestions provided here and solved the problem.

    Steps:

    1. Run dcomcnfg
    2. Go to Console Root \Component Services\Computers\My Computer\DCOM Config\Microsoft Excel Application
    3. Right click Microsoft Excel Application
    4. Select Properties
    5. Go to Identity tab
    6. Select The interactive user.

    In step 2, if you can't locate that path then try running mmc comexp.msc /32 instead of dcomcnfg.

    0 讨论(0)
提交回复
热议问题