【发布时间】:2010-10-27 20:15:17
【问题描述】:
我正在使用 Window Service 项目。必须按顺序将数据写入 Excel 文件中的工作表。
但有时,只是有时,服务在尝试使用单元格名称获取范围时抛出异常“Exception from HRESULT: 0x800A03EC”。
我已经把打开excel表格的代码放在这里了。
- 操作系统:window server 2003 Office:
- 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.
【问题讨论】:
-
你说“只是有时”的方式让我想到了这个问题的答案:stackoverflow.com/questions/20422387/…
-
我有同样的问题在 C# 代码中我输入了
xApp.Cells(3, 1).FormulaR1C1 = "=SUM(R[-2]C:R[-1]C)":失败;然后xApp.Cells(3, 1).FormulaR1C1 = "=(R[-2]C+R[-1]C)":失败;然后xApp.Cells(3, 1).FormulaR1C1 = "=A1+A2"成功