0

I am getting an error: Exception from HRESULT: 0x800A03EC whenever I set the formula for the range as:

        Range range = destinationSheet.Range["A1"];
        string[,] formulaString = new string[numberOfRows, 1];
        range = range.Resize[numberOfRows, 1];

        for (int count = 1; count <= numberOfRows; count++)
        {
            string worksheet = "Sheet1";
            string cellRef = "A1"
            string formula = string.Format("={0}!{1}", sourceSheetName, cellRef);
            formulaString[count-1, 0] = formula;                
        }

        range.set_Value(Type.Missing, formulaString); 
        range.Formula = range.Value;   // getting exception here

what might be the reason for this

Saurabh Kumar
  • 155
  • 2
  • 5
  • 19
  • possible duplicate : http://stackoverflow.com/questions/15597490/exception-from-hresult-0x800a03ec-error-while-saving-excel-file – Srinivas Aug 30 '13 at 05:14
  • You'll have to provide more code, we can't possibly tell what's wrong with just this line. – Marko Gresak Aug 30 '13 at 05:15
  • What are you trying to do with that last line? At least in VBA, the previous line is enough to assign the formulas. If you want to convert those formulas to values then `range.Value = range.Value` should do it. – Tim Williams Aug 30 '13 at 06:39
  • Yes Tim i am trying to convert those formulas to values, but even using: range.Value = range.Value is giving the same error – Saurabh Kumar Aug 30 '13 at 06:48

2 Answers2

0

The IIS user account has to have permissions to write the file.

Search for 0x800A03EC in the following article, How to Create Excel file in ASP.NET C#

Erwin
  • 2,770
  • 22
  • 22
0

It looks like you are trying to implement this: Range.set_Value(Missing.Value, arrayFormulas)

HRESULT: 0x800A03EC is an unknown (to VB.Net) COM error. This usually happens when Excel throws some error because your input or parameters were wrong.

In your case it means that Excel can handle the text just fine but when you try to put it in as a formula, it croaks. You need to check your formulas very carefully because Excel it telling you they are wrong.

Community
  • 1
  • 1
D_Bester
  • 5,040
  • 5
  • 29
  • 71