Handsontable example
HTML
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.css" />
<div id="example"></div>
JavaScript
const data = [
['Travel ID', 'Destination', 'Base price', 'Price with extra cost'],
['154', 'Rome', 400, '=SHEET_HEIGHT(ITACVD)'],
['155', 'Athens', 300, '=SHEET_HEIGHT()'],
['156', 'Warsaw', 150, '=SHEET_HEIGHT()'],
];
let hot;
/**
* Custom function plugin.
*/
class TmpPlugin extends HyperFormula.FunctionPlugin {
sheetheight(ast, state) {
console.log(ast.args);
return 1;
}
}
// Static property with the implemented function definitions.
TmpPlugin.implementedFunctions = {
SHEET_HEIGHT: {
method: 'sheetheight',
parameters: [
],
isVolatile: true,
}
};
const translations = {
'enGB': {
'SHEET_HEIGHT': 'SHEET_HEIGHT'
}
}
HyperFormula.registerFunctionPlugin(TmpPlugin, translations);
const container = document.getElementById('example');
hot = new Handsontable(container, {
data: data,
colHeaders: true,
rowHeaders: true,
height: 'auto',
formulas: {
engine: HyperFormula,
namedExpressions: [
{
name: 'ITACVD',
expression: '=Sheet1!$A$2'
}
]
},
licenseKey: 'non-commercial-and-evaluation'
});