Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you have functions that you use on a regular basis that are not in the built-in functions or if you wish to combine some of the built-in functions into a single function, you can do so by defining your own custom functions. They can be called as you would call any of the built-in functions.
Using Code
This example creates a custom function.

如果你自定义了一个方法,或者如果你希望将内建的方法组合成一个新的方法,你可以使用自定义方法。

你可以像调用任何内部函数一样调用自定义函数。

示例代码
以下代码创建了一个自定义函数

JavaScript

Copy Code

var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});var activeSheet = spread.getActiveSheet();//

Add Custom function

创建一个自定义函数

// Type =myfunc(1)//

in a cell to see the resultfunction

查看结果

function myfunc() {}myfunc.prototype = new GC.Spread.CalcEngine.Functions.Function("myfunc", 0, 0, {name: "myfunc",description: "This is my first function"});myfunc.prototype.evaluate = function (args) {    return 100;spread.addCustomFunction(new myfunc());