Excel 错误 HRESULT: 0x800A03EC 尝试使用单元格名称获取范围时 [英] Excel error HRESULT: 0x800A03EC while trying to get range with cell's name

查看:28
本文介绍了Excel 错误 HRESULT: 0x800A03EC 尝试使用单元格名称获取范围时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理 Window Service 项目.必须按顺序将数据写入 Excel 文件中的工作表.

I am working with Window Service project. that have to write data to a sheet in Excel file in a sequence times.

但有时,只是有时,该服务在尝试使用单元格名称获取范围时会抛出异常来自 HRESULT 的异常:0x800A03EC".

But sometimes, just sometimes, the service throw out the exception "Exception from HRESULT: 0x800A03EC" while it's trying to get range with cell's name.

我已经把打开excel表格和获取单元格的代码放在这里了.

I have put the code of opening excel sheet, and getting cell here.

  • 操作系统:window server 2003 Office:
  • Microsoft Office 2003 sp2

1:打开excel表格

1: Opening excel sheet

m_WorkBook = m_WorkBooks.Open(this.FilePath, 0, false, 5,
     "", "", true, Excels.XlPlatform.xlWindows, ";",
     true, false, 0, true, 0, 0);

2:让单元格写入

protected object m_MissingValue = System.Reflection.Missing.Value;
Range range = m_WorkSheet.get_Range(cell.CellName, m_MissingValue);
// error from this method, and cell name is string.

推荐答案

错误代码0x800A03EC(或-2146827284)表示NAME_NOT_FOUND;换句话说,您要求某事,而 Excel 找不到.

The error code 0x800A03EC (or -2146827284) means NAME_NOT_FOUND; in other words, you've asked for something, and Excel can't find it.

这是一个通用代码,它可以应用于很多它找不到的东西,例如使用当时无效的属性(如 PivotItem.SourceNameStandard )会在 PivotItem 未应用过滤器时引发此问题.Worksheets["BLAHBLAH"] 在工作表不存在等情况下抛出此问题.通常,您要求具有特定名称的内容但它不存在.至于为什么,这需要你自己挖掘.

This is a generic code, which can apply to lots of things it can't find e.g. using properties which aren't valid at that time like PivotItem.SourceNameStandard throws this when a PivotItem doesn't have a filter applied. Worksheets["BLAHBLAH"] throws this, when the sheet doesn't exist etc. In general, you are asking for something with a specific name and it doesn't exist. As for why, that will taking some digging on your part.

检查您的工作表是否确实包含您要求的范围,或者 .CellName 肯定会返回您要求的范围的名称.

Check your sheet definitely does have the Range you are asking for, or that the .CellName is definitely giving back the name of the range you are asking for.

这篇关于Excel 错误 HRESULT: 0x800A03EC 尝试使用单元格名称获取范围时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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