我正在使用Window Service项目。必须按顺序将数据写入Excel文件中。Excel错误HRESULT:0x800A03EC尝试获取单元格名称的范围
但有时候,有时候,当服务试图获取单元格名称的范围时,该服务抛出异常“异常来自HRESULT:0x800A03EC”。
我已经把打开excel表的代码,并在这里获取单元格。
- OS:视窗服务器2003处:
- 的Microsoft Office 2003 SP2
1:打开Excel工作表
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.
你说“有时候”的方式让我想到这个答案:http://stackoverflow.com/questions/20422387/adding-formula-to-cell-exception-from-hresult-0x800a03ec/26591841# 26591841 – 2014-10-27 16:11:26
我有同样的问题 在C#代码中,我键入`xApp.Cells(3,1).FormulaR1C1 =“= SUM(R [-2] C:R [-1] C)”`:failed;那么`xApp.Cells(3,1).FormulaR1C1 =“=(R [-2] C + R [-1] C)”`:失败;然后`xApp.Cells(3,1).FormulaR1C1 =“= A1 + A2”`成功 – 2016-07-12 10:52:53