System.Runtime.InteropServices.COMException(0x800A03EC)

发布于 2024-10-07 03:57:51 字数 635 浏览 8 评论 0原文

Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs() 方法在 Windows Server 2003 和 XP 上工作正常,但在 Windows Server 2008 上不行。我复制了它,因为它提供了所有 Dll 和权限

我也尝试了网上给出的所有解决方案,例如文化设置和DCOM权限。

出现以下错误:

System.Runtime.InteropServices.COMException(0x800A03EC):异常 来自 HRESULT:0x800A03EC

0x800A03EC

Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(对象文件名, 文件格式对象、密码对象、WriteResPassword 对象、对象 ReadOnlyRecommended、对象 CreateBackup、XlSaveAsAccessMode 访问模式、对象冲突解决方案、对象 AddToMru、对象 TextCodepage、对象 TextVisualLayout、对象 Local)

请帮忙..!

Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs() method is working fine on Windows server 2003 and also on XP but not on Windows server 2008. I copied it as it is gave all Dll's and permissions

I have also tried all the solutions given on the net, such as Culture settings and DCOM permission.

Getting following error:

System.Runtime.InteropServices.COMException (0x800A03EC): Exception
from HRESULT: 0x800A03EC

at

Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename,
Object FileFormat, Object Password, Object WriteResPassword, Object
ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode
AccessMode, Object ConflictResolution, Object AddToMru, Object
TextCodepage, Object TextVisualLayout, Object Local)

Please help ..!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

唠甜嗑 2024-10-14 03:57:51

找到答案了……!!!!!!

Microsoft 正式在 Windows Server 2008 上不支持 Microsoft Office 2003 Interop。

但经过大量的排列&结合代码和搜索,我们找到了一种适合我们场景的解决方案。

解决方案是弥补 Windows 2003 和 2008 维护其文件夹结构的方式之间的差异,因为 Office Interop 依赖于桌面文件夹来中间打开/保存文件。 2003 系统在 systemprofile 下放置了桌面文件夹,而 2008 中则没有该

文件夹。因此,当我们在 2008 年的相应层次结构下创建此文件夹时,如下所示: Office Interop 能够根据需要保存文件。 下创建此桌面文件夹

需要在C:\Windows\System32\config\systemprofile

C:\Windows\SysWOW64\config\systemprofile

这对我有用...

还要检查是否安装了 .NET 1.1,因为它需要Windows Server 2008 预安装的 Interop 和 ot

或者您也可以使用 SaveCopyas() 方法,只需将参数作为文件名字符串)

谢谢大家..!

Found Answer.......!!!!!!!

Officially Microsoft Office 2003 Interop is not supported on Windows server 2008 by Microsoft.

But after a lot of permutations & combinations with the code and search, we came across one solution which works for our scenario.

The solution is to plug the difference between the way Windows 2003 and 2008 maintains its folder structure, because Office Interop depends on the desktop folder for file open/save intermediately. The 2003 system houses the desktop folder under systemprofile which is absent in 2008.

So when we create this folder on 2008 under the respective hierarchy as indicated below; the office Interop is able to save the file as required. This Desktop folder is required to be created under

C:\Windows\System32\config\systemprofile

AND

C:\Windows\SysWOW64\config\systemprofile

This worked for me...

Also do check if .NET 1.1 is installed because its needed by Interop and ot preinstalled by Windows Server 2008

Or you can also Use SaveCopyas() method ist just take onargument as filename string)

Thanks Guys..!

那支青花 2024-10-14 03:57:51

试试这个,因为它对我有用......

  1. 转到“开始”-> “运行”并输入“dcomcnfg”
  2. 这将打开组件服务窗口,展开“Console Root”->“ “计算机”-> “DCOM 配置”
  3. 在组件列表中查找“Microsoft Excel 应用程序”。
  4. 右键单击该条目并选择“属性”
  5. 转到属性对话框上的“身份”选项卡。
  6. 选择“交互式用户”。

提供这里提到的最后一段

Try this as it worked for me...

  1. Go to "Start" -> "Run" and enter "dcomcnfg"
  2. This will bring up the component services window, expand out "Console Root" -> "Computers" -> "DCOM Config"
  3. Find "Microsoft Excel Application" in the list of components.
  4. Right click on the entry and select "Properties"
  5. Go to the "Identity" tab on the properties dialog.
  6. Select "The interactive user."

courtesy of Last paragraph mentioned in here

能否归途做我良人 2024-10-14 03:57:51

一些谷歌搜索显示您可能有一个损坏的文件:

http: //bitterolives.blogspot.com/2009/03/excel-interop-comexception-hresult.html

并且您可以告诉 excel 使用 CorruptLoad 参数打开它,例如...

Workbook workbook = excelApplicationObject.Workbooks.Open(path, CorruptLoad: true);

Some googling reveals that potentially you've got a corrupt file:

http://bitterolives.blogspot.com/2009/03/excel-interop-comexception-hresult.html

and that you can tell excel to open it anyway with the CorruptLoad parameter, with something like...

Workbook workbook = excelApplicationObject.Workbooks.Open(path, CorruptLoad: true);
木格 2024-10-14 03:57:51

我在尝试保存 Excel 文件时看到了同样的错误。当我使用 MS Office 2003 时,该代码运行良好,但在升级到 MS Office 2007 后,我开始看到这种情况。每当我尝试将 Excel 文件保存到服务器或远程文件共享时,就会发生这种情况。

我的解决方案虽然很初级,但效果很好。我只是让程序将文件保存在本地,例如用户的 C:\ 驱动器。然后使用“System.IO.File.Copy(File, Destination, Overwrite)”方法将文件移动到服务器。然后您可以删除C:\驱动器上的文件。

效果很好,而且很简单。但不可否认,这不是最优雅的方法。

希望这有帮助!我在网上寻找解决方案时遇到了很多困难,直到这个想法突然出现在我的脑海中。

I was seeing this same error when trying to save an excel file. The code worked fine when I was using MS Office 2003, but after upgrading to MS Office 2007 I started seeing this. It would happen anytime I tried to save an Excel file to a server or remote fie share.

My solution, though rudimentary, worked well. I just had the program save the file locally, like to the user's C:\ drive. Then use the "System.IO.File.Copy(File, Destination, Overwrite)" method to move the file to the server. Then you can delete the file on the C:\ drive.

Works great, and simple. But admittedly not the most elegant approach.

Hope this helps! I was having a ton of trouble finding any solutions on the web till this idea popped into my head.

烟雨凡馨 2024-10-14 03:57:51

对于所有仍然遇到这个问题的人,我只花了 2 天的时间来追踪这个该死的事情。
当数据集中没有行时,我遇到了同样的错误。
看起来很明显,但错误消息非常模糊,因此需要 2 天。

For all of those, who still experiencing this problem, I just spent 2 days tracking down the bloody thing.
I was getting the same error when there was no rows in dataset.
Seems obvious, but error message is very obscure, hence 2 days.

若水微香 2024-10-14 03:57:51

IIS运行时出现权限问题
我遇到了这个问题,我以这种方式解决了它,

我进入了文件夹

C:\Windows\ System32\config\SystemProfile

C:\Windows\SysWOW64\config\SystemProfile

是受保护的系统文件夹,它们通常有锁。

右键单击->卡安全->点击编辑->添加取消“Autenticadet User”并分配权限。

至此一切都解决了,如果还有问题尝试将所有权限授予“Everyone”

It 'a permission problem when IIS is running
I had this problem and I solved it in this way

I went on folders

C:\Windows\ System32\config\SystemProfile

and

C:\Windows\SysWOW64\config\SystemProfile

are protected system folders, they usually have the lock.

Right-click-> Card security-> Click on Edit-> Add untente "Autenticadet User" and assign permissions.

At this point everything is solved, if you still have problems try to give all permissions to "Everyone"

简美 2024-10-14 03:57:51

就我而言,问题是将标题样式设置为“标题 1”,但该样式在我收到错误的 Word 中不存在,因为它不是英语语言的 Office。

In my case, the problem was styling header as "Header 1" but that style was not exist in the Word that I get the error because it was not an Office in English Language.

凉城已无爱 2024-10-14 03:57:51

由于 Excel 文件的路径,我遇到了这个问题,每当我尝试打开 Excel 文件时,我都会收到错误消息(即我的 Excel 文件有一个很长的路径,如 C:\Users\Blabla\Blabla\MyVeryLongFolderHierarchyPath\MyExcelFile.xlsx )

解决方案是直接将我的 Excel 文件放在较短的文件路径(如 C:\MyExcelFile.xlsx)下。我不敢相信 2021 年会因为长文件路径而发生如此愚蠢的问题

I had this problem due to the path of an excel file and whenever I tried to open the excel file I got the error message (i.e. my excel file had a long path like C:\Users\Blabla\Blabla\MyVeryLongFolderHierarchyPath\MyExcelFile.xlsx)

The solution was to carry my excel file under a shorter filepath (like C:\MyExcelFile.xlsx) directly. I can not believe such a stupid problem occurs due to long file paths in year 2021

烟燃烟灭 2024-10-14 03:57:51

我偶然发现的一个奇怪的解决方案是查看是否有任何 Excel 进程在后台运行。确保代码实际上会自行清理并关闭所有 Excel 进程。

A strange solution I stumbled upon is to see if there are any Excel processes running in the background. Make sure code is in fact cleaning up after itself and closing all Excel processes.

叹梦 2024-10-14 03:57:51

我在写入工作簿单元格时遇到此异常。
问题是单元格是从 1 而不是 0 开始索引的:

坏:

activeSheet.Cells[0, 0].Value = 1;

好:

activeSheet.Cells[1, 1].Value = 1;

I got this exception when writing to my workbook cells.
The problem was that the cells are indexed from 1 and not 0:

Bad:

activeSheet.Cells[0, 0].Value = 1;

Good:

activeSheet.Cells[1, 1].Value = 1;
倚栏听风 2024-10-14 03:57:51

我在代码中发现同样的问题是由于输入错误的公式引起的。我的系统设置为德语,但在这种情况下,我实际上必须用英语输入 Excel 公式。之后打开文档,会以德语显示公式。

I found the same issue in my code being caused by entering faulty formulas. My system is set to german but in this case i actually have to input the excel formula in english. Opening the document afterwards, shows the formula back in german.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文