Excel error HRESULT: 0x800A03EC while trying to get range with cell#39;s name(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.
但有时,只是有时,服务在尝试使用单元格名称获取范围时抛出异常Exception from 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 未应用过滤器时,使用当时无效的属性(如 PivotItem.SourceNameStandard
)会抛出此错误.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 尝试使用单元格名称获取范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Excel 错误 HRESULT: 0x800A03EC 尝试使用单元格名称获
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01