Posted 15 November 2018, 9:53 pm EST
Hello,
Thanks for correcting us. Here is the complete working sample and code for future reference:-
<script type="text/javascript">
$(document).ready(function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 });
initSpread(spread);
});
function initSpread(spread) {
var spreadNS = GC.Spread.Sheets;
var sheet = spread.getSheet(0);
function Sample2ValueFunction() {
}
Sample2ValueFunction.prototype = new GC.Spread.CalcEngine.Functions.Function("SAMPLE", 0, 0);
Sample2ValueFunction.prototype.evaluate = function () {
function MyArray(array) { this.array = array; }
MyArray.prototype = new GC.Spread.CalcEngine.CalcArray();
MyArray.prototype.getRowCount = function () { return this.array.length; }
MyArray.prototype.getColumnCount = function () { return this.array[0].length; }
MyArray.prototype.getValue = function (row, col) { return this.array[row][col]; }
var myArray = new MyArray([["1st", "2nd", "3rd", "4th"]]);
return myArray;
}
var samplefunc = new Sample2ValueFunction();
$("#addCustomFunction").click(function () {
sheet.addCustomFunction(samplefunc);
sheet.setArrayFormula(0, 0, 1, 4, "=sample()");
});
};
</script>
Thanks,
Reeva
CustomFunction_ArrayFormulaV12(Modified).zip