Excel Exception from HRESULT: 0x800A03EC when writing to a Excel cell
Asked Answered
R

2

1

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.

Recede answered 7/3, 2016 at 10:17 Comment(1)
What are the actual values of i and column when you get the error? Also pasting incomplete code samples does not help. It now looks odd and unclear. There is a column=1 and column++ but no loop over the columns.Arose
S
1

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

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

Sidero answered 8/2, 2017 at 2:40 Comment(0)
S
0

Try this:

Excel.Application MyApp = new Excel.Application { Visible = false, DisplayAlerts = false };
System.Threading.Thread.CurrentThread.CurrentCulture = new 
System.Globalization.CultureInfo("en-US");
Supplication answered 6/8, 2018 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.