NetOffice を使用して Excel スプレッドシートを編集しています。Excel のユーザー定義関数からコードを呼び出すと、呼び出し元のスプレッドシートを編集できません。
Excel.Application excelApplication = Excel.Application.GetActiveInstance();
Excel.Worksheet workSheet = (Excel.Worksheet) excelApplication.ActiveSheet;
Excel.Range cell = workSheet.Cells[2, 2];
object value = cell.Value; //works
cell.Value = 3; //Throws Exception
これを可能にする回避策はありますか?
例外は
"System.Runtime.InteropServices.COMException (0x80004005): 詳細については内部例外を参照してください。 ---> System.Reflection.TargetInvocationException: 呼び出しのターゲットによって例外がスローされました。 ---> System.Runtime. InteropServices.COMException: HRESULT からの例外: 0x800A03EC --- 内部例外スタック トレースの終わり --- System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String)名前、BindingFlags invokeAttr、バインダー バインダー、オブジェクト ターゲット、Object[] args、CultureInfo culture) の NetOffice.Invoker.PropertySet(COMObject comObject, String name, Object[] value) at NetOffice.Invoker.PropertySet(COMObject comObject, String name, Object[] value) at NetOffice.ExcelApi.Range.set_Value(Object value) ) \psf\home\Documents\Visual Studio 2013\Projects\Excel-REPL\Excel-REPL\Example01.cs の ExcelExamplesCS45.Example01.RunExample(): \psf\home の ClojureExcel.MainClass.Test() の 29 行目\Documents\Visual Studio 2013\Projects\Excel-REPL\Excel-REPL\MainClass.cs: 310 行目"\psf\home\Documents\Visual Studio 2013\Projects\Excel-REPL\Excel-REPL\MainClass.cs:line 310 の ClojureExcel.MainClass.Test() の 29 行目"\psf\home\Documents\Visual Studio 2013\Projects\Excel-REPL\Excel-REPL\MainClass.cs:line 310 の ClojureExcel.MainClass.Test() の 29 行目"