写入Excel单元格时为0x800A03EC

写入Excel单元格时为0x800A03EC

本文介绍了来自HRESULT的Excel异常:写入Excel单元格时为0x800A03EC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这里已经讨论过了,但是我找不到解决方案。
在使用C#中的Microsoft.Office.Interop.Excel(HRESULT的异常:0x800A03EC)时,我收到此错误。
这是我的代码:

  for(int i = 1; i< = max; i ++)
{
int column = 1
...
double averageDistance = sum / distanceCount; // sum和distanceCount是double
myWorksheet1.Cells [i,column] = averageDistance; //这里我得到了例外。
column ++;
...
}

我知道有些人使用非 - 基于单元格的索引[,],但是您可以看到我的索引从1开始。任何人都可以帮忙吗?
谢谢。

解决方案

是因为您没有更改单元格的价值吗?



尝试:
myWorksheet1.Cells [i,column] .Value = averageDistance;


I know that this has been discussed here, but I can not find solution.I am getting this error while working with Microsoft.Office.Interop.Excel in C# (Exception from HRESULT: 0x800A03EC).Here is my code:

 for (int i = 1; i <= max; i++)
 {
  int column = 1
  ...
  double averageDistance = sum / distanceCount;   //sum and distanceCount are type double
  myWorksheet1.Cells[i, column] = averageDistance;  // Here I am getting the exception.
  column++;
  ...
 }

I know that some people solved this using non-zero based index in Cells[,], but as you can see my indexes are starting from 1. Can anyone help please?Thank you.

解决方案

Is it because you are not changing the Value of the cell?

Try:myWorksheet1.Cells[i, column].Value = averageDistance;

这篇关于来自HRESULT的Excel异常:写入Excel单元格时为0x800A03EC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 13:02