【发布时间】:2018-08-06 22:13:47
【问题描述】:
我知道这里已经讨论过了,但我找不到解决方案。 在 C# 中使用 Microsoft.Office.Interop.Excel 时出现此错误(HRESULT 异常:0x800A03EC)。 这是我的代码:
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++;
...
}
我知道有些人在 Cells[,] 中使用基于非零的索引解决了这个问题,但是您可以看到我的索引从 1 开始。有人可以帮忙吗? 谢谢。
【问题讨论】:
-
遇到错误时 i 和 column 的实际值是多少?粘贴不完整的代码示例也无济于事。现在看起来很奇怪而且不清楚。有一个 column=1 和 column++ 但没有在列上循环。