excel 0x800A03EC 错误一则

关于0x800A03EC 的excel错误已经在网上搜搜刮刮两个礼拜了,但是一直没有头绪,实在不知道当前的错误对应着网上说的哪个类型,而且每个类型的错误解决方法也并不一定都有明确说明,这个让人很头疼。

1. There’s a mis-match between the Office interface language and the Windows Regional language

2. The cell address is invalid for the action you propose

3. Excel is in editing mode and can therefore not accept in-coming commands

原本没有用递归的时候其实都是好好的,所有的一切都跟MSDN上示例演示的一样一样的,但是一进入递归调用函数就傻逼了,晚上想在睡觉前再看看有什么办法,就试一试验证一下是不是第二种错误。实际尝试代码修改如下:

  1. foreach (var bEle in bDoc)
  2. {
  3. if (bEle.Value.IsBsonDocument)
  4. {
  5. // BsonElement名
  6. curWorkSheet.Cells[curRow, curCol] = bEle.Name; // 刚刚进入递归操作Excel就完蛋,问题出在curRow, curCol的数值上
  7. // BsonElement子节点
  8. curCol++;
  9. BsonDocument subBDoc = (BsonDocument)bEle.Value;
  10. this.PrintExcel(ref curWorkSheet, subBDoc, curRow, curCol);
  11. }
  12. else
  13. {
  14. curWorkSheet.Cells[curRow, curCol] = bEle.Name.ToString();
  15. curWorkSheet.Cells[curRow, curCol + 1] = bEle.Value.ToString();
  16. //curRow++; //把这两行注释
  17. //curCol–;
  18. curRow = curRow + 2; // 换成其他的cell试试
  19. curCol = curCol + 2;
  20. }
  21. }

最后出来的excel表格其实是错的,因为单元格跟实际要求的对不上,但是好歹没有之前那个王八蛋错误了,不过实际还是得解决那个错误,原先该写的单元格还得写。

Posted in