相关疑难解决方法(0)

来自HRESULT的异常:0x800A03EC错误

使用以下代码运行Excel加载项时出现"HRESULT:0x800A03EC"错误:

Excel.Range rng = ActiveSheet.Cells[x, y] as Excel.Range;                
string before = rng.Value2; 
string cleanV = System.Text.RegularExpressions.Regex.Replace(before, @"\s+", "");
rng.set_Value(cleanV);
Run Code Online (Sandbox Code Playgroud)

当错误发生时,X和Y设置为1,因此不会违反Excel范围.我进行了广泛的搜索并尝试了多种设置单元格值的方法(例如,Cells [x,y],range.set_Value()),但是为什么会发生这种错误以及如何避免它.

任何帮助是极大的赞赏.

以下是例外情况:


System.Runtime.InteropServices.COMException was unhandled by user code
  HResult=-2146827284
  Message=Exception from HRESULT: 0x800A03EC
  Source=""
  ErrorCode=-2146827284
  StackTrace:
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Range.set_Value(Object RangeValueDataType, Object value)
       at ImportValidation.ThisAddIn.removeAnySpaces(Int32 x, Int32 y) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\ThisAddIn.cs:line 354
       at ImportValidation.ThisAddIn.ReadHeaders(Hashtable columnAddress) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\ThisAddIn.cs:line 123
       at ImportValidation.ThisAddIn.mapColumns() in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\ThisAddIn.cs:line 493
       at ImportValidation.Ribbon1.button6_Click(Object …
Run Code Online (Sandbox Code Playgroud)

c# excel interop add-in exception

59
推荐指数
3
解决办法
24万
查看次数

标签 统计

add-in ×1

c# ×1

excel ×1

exception ×1

interop ×1