尝试使用Microsoft.Office.Interop.Excel.Workbooks.Open()打开Excel时出现异常HResult 0x800a03ec [英] Exception HResult 0x800a03ec when trying to open Excel with Microsoft.Office.Interop.Excel.Workbooks.Open()

查看:979
本文介绍了尝试使用Microsoft.Office.Interop.Excel.Workbooks.Open()打开Excel时出现异常HResult 0x800a03ec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试在客户端计算机上打开excel文件,则会引发以下异常:

Following Exception is thrown if I try to open an excel file on a client machine:

Exception from HRESULT: 0x800A03EC

内部异常:(空)

堆栈跟踪:

   at Microsoft.Office.Interop.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)
   at (own assembly)

此HResult是一个非常普通的错误,我无法通过它找到任何有用的信息.

This HResult is a very generic Error, I could not find any useful informations by it.

我的设置:

在Windows服务中运行的WCF服务.完全相同的安装程序正在其他三台计算机上运行.

WCF Service running inside a Windows Service. The exact same Setup is working on three other machines.

我可以排除的事情:

  • 路径错误
  • 文件不存在
  • 文件已损坏
  • 文件受写保护

我所做的事情:

  • 创建了桌面文件夹,如此处所示(第二个答案) https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/4d6c383a-94eb-4898-9d22-aa4bb69be25b/
  • 授予桌面文件夹所有人"或杰德"权限(杰德"等同于德语中的所有人")
  • 从当前活跃用户启动服务
  • 按照Heidi2的建议更改了Excel的DCOM Config(请参见上面的链接)
  • 从Office 365更改为Office Professional Plus
  • 尝试打开文件时将区域设置设置为en
  • 应该手动打开的文件:excel中没有错误/警告/用户对话框
  • 在目标计算机上安装了英语-美国
  • 编写了一个非WCF服务,该服务会启动执行Interop请求的dll
  • 编写一个控制台应用程序,该应用程序启动执行Interop请求的dll
  • Created the Desktop folders as seen here (second Answer) https://social.msdn.microsoft.com/Forums/vstudio/en-US/4d6c383a-94eb-4898-9d22-aa4bb69be25b/
  • Gave the Desktop Folders "Everyone" or "Jeder" Permissions ("Jeder" is the equivalent of "Everyone" in German)
  • Started the Service with the currenlty active User
  • Changed the DCOM Config for Excel as advised by Heidi2 (see Link above)
  • Changed from Office 365 to Office Professional Plus
  • Locale is set to en-US while trying to open the file
  • Opened file manually which is supposed to be opened: no errors / warnings / user dialogs from excel
  • Installed English - US on target machine
  • Wrote an non WCF Service which starts the dll which executes the Interop request
  • Wrote an Console Application which starts the dll which executes the Interop request

一些观察:

  • 如果我删除了Desktop文件夹(请参阅我的第一个我已经完成的事情"),则会收到描述并在此处解决的错误: Microsoft Office Excel无法访问文件'c:\ inetpub \ wwwroot \ Timesheet \ App_Data \ Template.xlsx'
  • 在dll尝试打开excel文件时,Excel在任务管理器中短暂打开了
  • 我已安装Office 365,但在任务管理器中选择了Office Click-Once任务,有时会冻结应用程序.这就是为什么我改用Professional Plus的原因
  • 如果活动语言设置为美国英语",则不会再引发此错误;但是本应由Interop渲染的图像却被渲染为空白
  • If I remove the Desktop folders (see my first "Things I've done"), I get the error as described and resolved here: Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'
  • Excel is open for a short time in the task manager while the dll tries to open the excel file
  • while I've had Office 365 installed, Office Click-Once Tasks opped up in Task Manager, sometimes freezing the Application. That's why I've switched to Professional Plus
  • If the active language is set to English US, this error is not thrown anymore; but images, which are supposed to be rendered by Interop, are rendered blank

我在这里想念什么?

推荐答案

在尝试此解决方案之前,请确保您已阅读问题的我所做的事情"段落(并尝试了适用于您的内容)

打开文档时引发异常;在生成Excel的计算机上,文件生成无效.

The Exception was thrown upon opening the Document; on the machine which generated the Excels, the files were generated invalid.

解决方案是更改数字格式.

The solution was to change the Format of the numbers.

进入系统配置->时间,语言和地区->语言

Go into System Configuration -> Time, Language and Region -> Language

点击突出显示的超链接

打开高级设置

将定界符更改为点".

Change the delimiter to a point "."

这篇关于尝试使用Microsoft.Office.Interop.Excel.Workbooks.Open()打开Excel时出现异常HResult 0x800a03ec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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