I have the following code in my DNA DNA plugin
In my AutoOpen method, I will put the following code:
ExcelIntegration.RegisterUnhandledExceptionHandler(ex => ex.ToString());
I have the following function that is called from my excel sheet.
[ExcelFunction(Category = "Foo", Description = "Sets value of cell")] public static Foo(String idx) { Excel.Application app = (Excel.Application)ExcelDnaUtil.Application; Excel.Workbook wb = app.Workbooks[1]; Excel.Worksheet ws = GetSheet("Main");
The problem is that I cannot set the cell values. When I call the method, it causes an error in the last line.
My error handler gives me the following error:
{System.Runtime.InteropServices.COMException (0x800A03EC)
I also tried setting the cell value as follows:
r = (Excel.Range)ws.Cells[12, 22]; const int nCells = 1; Object[] args1 = new Object[1]; args1[0] = nCells; r.GetType().InvokeMember("Value2", BindingFlags.SetProperty, null, r, args1);
With the same result.
Can anyone point out what I can do wrong here?
source share