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# 9 新特性——record的相关总结 2023-04-03
- 将数据集转换为列表 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 如果条件可以为空 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
