Cannot open Excel file in C#

后端 未结 4 1710
天涯浪人
天涯浪人 2021-02-19 21:51

I have the following C# function in my project, which is supposed to open and return an existing Excel workbook object:

Application _excelApp;

// ...

private W         


        
4条回答
  •  佛祖请我去吃肉
    2021-02-19 21:55

    I was running into the same issue and I have investigated infomation about "registry hack".

    After all, I found another solution that changes no registry values and everything works on properly.

    This solution is ...

    ・Windows 2008 Server x64

    Please make this folder.

      C:\Windows\SysWOW64\config\systemprofile\Desktop
    

    ・Windows 2008 Server x86

    Please make this folder.

     C:\Windows\System32\config\systemprofile\Desktop
    

    ...instead of dcomcnfg.exe.

    This operation took away office automation problems in my system.

    A Desktop folder seems to be necessary in the systemprofile folder to open file by Excel.

    It disappears from Windows2008, Windows2003 had the folder, and I think it cause this error.

    I think it is safer than "registry hack".

    If you try this solution, please let me know results.

提交回复
热议问题