Update matrix result in active cell vs. original (formula) cell
Mathefreak007 opened this issue · comments
Actually the result matrix is created in the active sheet starting at active cell.
Usually it should be created starting the original cell containing the function call.
Example:
- function fn(string s, int start, int end) gives back a column vector of numbers
- We have two cases:
s="M" --> result is the vector [start, start+1, start+2, ..., end]
s="F" --> result is the vector [start+10, start+11, start+12, ..., end+10]
Assume we write the formula in cell A5 and we use cell A1 as reference for the first parameter s.
So:
- A1 contains M
- in A5 we write the formula: =fn(A1;1;100)
That produces the vector [1,2,3,...,100] in cells A5,A6,A7,...,A105
Now we change the parameter in cell A1 from M to F.
That produces the vector [11,12,13,...,110] in cells A2,A3,A4,...,A102
So the second function call overwrites the function in cell A5.
(My) expectation:
result is updated in the original area, in the example in cells A5,A6,...
I think, the problem is using the active cell instead of the cell containing the function call which is actually performed.
public object display()
{
Excel.Application app = (Excel.Application)ExcelDnaUtil.Application;
Excel.Worksheet worksheet = (Excel.Worksheet)app.ActiveWorkbook.ActiveSheet;
Excel.Range startCell = app.ActiveCell;
var propKey = "" + startCell.Row + PROPERTY_DIVIDER + startCell.Column;
Hope my explanation is clear enough.