在microsoft.office.interop.excel.workbooks.Add(对象模板)的COM异常hresult 0x800a03ec [英] COM Exception hresult 0x800a03ec at microsoft.office.interop.excel.workbooks.Add (object template)

查看:477
本文介绍了在microsoft.office.interop.excel.workbooks.Add(对象模板)的COM异常hresult 0x800a03ec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于Windows的应用程序,该应用程序使用COM Interop Excel,其中excel导出失败。这适用于开发环境。但是当它升级到其他环境时就会失败。



另外问题是它在当地环境中不可重现。



我们正在使用Microsoft.Interop.Excel打开excel并更新数据。



尝试使用Workbooks.Add方法添加工作簿时我们得到了以下

错误:





来自HRESULT的System.Runtime.InteropServices.COMException.Exception:0X800A03EC

at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)



代码:



thisWorkbook = OpenTemplate(new System.IO.FileInfo(XLSTemplate\\Test.xlsx));





公共工作簿OpenTemplate(FileInfo xlsFile)

{

工作簿wb = null;



试试

{

wb = Workbooks.Add(xlsFile.FullName);

template = xlsFile;



if(wb!= null)



{

if(!DebugOut.IsDebug&wb.Worksheets.Count> 0)

((_ workheet)wb.Worksheets [1])。激活();

}

}

catch(exception ex)

{

System.Diagnostics.Debug.WriteLine(ex);

抛出新的异常(错误在OpenTemplate,ex);

}

返回wb;

}



任何帮助和解决方案都会得到很大的帮助。

I am using a Windows based application which uses COM Interop Excel in which the excel exports fails. This works in the development environment. But it fails when promoted to other environment.

Also the problem is it is not reproducible in local environment.

We are using Microsoft.Interop.Excel for opening the excel and updating the data.

While trying to add the workbook using Workbooks.Add method we are getting the following
error :


System.Runtime.InteropServices.COMException.Exception from HRESULT:0X800A03EC
at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)

Code :

thisWorkbook = OpenTemplate(new System.IO.FileInfo("XLSTemplate\\Test.xlsx"));


public Workbook OpenTemplate(FileInfo xlsFile)
{
Workbook wb = null;

try
{
wb = Workbooks.Add(xlsFile.FullName);
template = xlsFile;

if (wb != null)

{
if (!DebugOut.IsDebug & wb.Worksheets.Count > 0)
((_Worksheet)wb.Worksheets[1]).Activate();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
throw new Exception("Error in OpenTemplate",ex);
}
return wb;
}

Any help and solution would be much appreaciated.

推荐答案

两种环境下的操作系统都不同吗?是Window 2008 Server吗?如果是这样的话,尝试创建如下所示的Desktop文件夹,如果在失败的环境中已经不存在的话。



Windows 2008 Server(64位):C:\ Windows \\ \\ SysWOW64 \config \systemprofile \Desktop

Windows 2008 Server(32位):C:\ Windows \ System32 \ config \systemprofile \Desktop
Are the OS different in both environment? Is it Window 2008 Server? If so try creating Desktop folder as below if not present already in the environment where this is failing.

Windows 2008 Server (64 Bit): C:\Windows\SysWOW64\config\systemprofile\Desktop
Windows 2008 Server (32 Bit): C:\Windows\System32\config\systemprofile\Desktop


这篇关于在microsoft.office.interop.excel.workbooks.Add(对象模板)的COM异常hresult 0x800a03ec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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