Spreadsheet Functions
On this page
With this plugin you can create your own spreadsheet functions.
Definition
Spreadsheet functions are defined in the contributions.json
file. A spreadsheet function is described by the following JSON:
{
"id": "string", // required
"src": "string", // required
"description": "string" // optional
}
id
Used for referencing the spreadsheet function.src
The relative path to the spreadsheet function implementation.description
An optional description, mainly used for administrators.
A spreadsheet function must implement the interface SpreadsheetFunction
.
Example
In this example we want to build a simple function that always adds 5 to the input. We name the function ADD_5
, and it should have the following behaviour:
=ADD_5(1) // returns 6
=SUM(4, ADD_5(1)) // returns 10
Implementation
src/functions/add-5-function.js:
export class Add5Function {
getName() {
return 'ADD_5';
}
getValue(params) {
return params[0] + 5;
}
}
contributions.json
contributions.json
The following snippet defines the data loader, thus making it available for data upload:
{
...
"contributions": {
"plugins": [
{
"id": "add5FunctionId",
"src": "src/functions/add-5-function",
"description": "This functions always add 5 to the input.",
"types": ["spreadsheet_function"]
}
]
}
}