Hi,
we are using the .NET version of your product and we are trying to trigger a calculation of an excel sheet which includes custom functions that return arrays and we need to auto expand the formulas.
I followed the instructions in Set an array formula without knowing the range of cells but this didn’t work. What I am observing is that if I set to adjacent cells with the same formula then one of them will auto-expand and populate the cells with values but one on its own will not show any values.
Below is the code I have used.
var workbook = new Workbook(args[0]);
workbook.Settings.CalcMode = CalcModeType.Manual;
Cells cells = workbook.Worksheets[0].Cells;
Cell cell = cells[0, 0];
cell.SetArrayFormula("=MyUdf()", 1, 1);
// if you uncomment the code below then you can see values for the first formula but not the second
//Cell cell2 = cells[0, 1];
// cell2.SetArrayFormula(“=MyUdf()”, 1, 1);
workbook.CalculateFormula(true, new MyCustomFunctions());
public class MdapCustomFunctions : ICustomFunction
{
public object CalculateCustomFunction(string functionName, ArrayList paramsList, ArrayList contextObjects)
{
var cell = (Cell)contextObjects[2];
var result = new object[][] {
new object[]{new DateTime(2015, 6, 12, 10, 6, 30), 2},
new object[]{3.0, "Test"}
};
cell.SetArrayFormula(cell.Formula, 2, 2);
return result;
}
}
Could you please provide some guidance on this?
Thanks,
Alex