[C#.net]xlApp.Workbooks.Open打开无法远程访问

上月还能使用的xlApp.Workbooks.Open,这个月报无法远程访问,搞了半天,才找到原因是Foxit PDF 的Execl插件搞的鬼,记录下

Excel.Workbooks wbChecks = xlApp.Workbooks;
                File.Copy(txtCheck.Text, Environment.CurrentDirectory+"\Check.xlsx", true);
                wbCheck = xlApp.Workbooks.Open(Environment.CurrentDirectory+"\Check.xlsx", Type.Missing, Type.Missing,
              Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
              Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                Excel.Workbooks wbOuts = xlApp.Workbooks;

方法一:可以设置 wk.Visible=true; 但是这种方法将excel打开了,展现效果不好。

方法二:在excel2007里,点击“office按钮”,点击“excel选项”,点开后点击“加载项”,在最下方下拉框中选择“COM加载项”,点击“转到”按钮,会弹出框,把里面pdf的加载项去掉,就OK了。

网上参考的链接

c#调用excel报错(异常来自HRESULT:0X80010105(RPC_SERVERFAULT))

https://blog.csdn.net/dongzhen190/article/details/79718472

C#读excel出现异常 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))

https://ask.csdn.net/questions/376475

原文地址:https://www.cnblogs.com/masonlu/p/11308361.html