For some reason, the Handsontables are not working (they don’t show up at all / don’t render) when I use the “cell” and “formulas” options together with multiple worksheets.
The line that is causing the issue is when I use “this.instance.getData();” in the “cells”. It works when I don’t use the “formulas” option, but when I do, it stops working.
Code:
const hyperformulaInstance = HyperFormula.buildEmpty({
licenseKey: 'internal-use-in-handsontable',
});
hyperformulaInstance.addSheet('Sheet1')
hyperformulaInstance.addSheet('Sheet2')
const data1 = [
['Sheet1 A1', 'Sheet1 B1', '=Sheet2!A1'],
['Sheet1 A2', 'Sheet1 B2', '=Sheet2!A2'],
];
const data2 = [
['Sheet2 A1', 'Sheet2 B1', '=Sheet1!A1'],
['Sheet2 A2', 'Sheet2 B2', '=Sheet1!A2'],
];
const container1 = document.querySelector('#example1');
const hot1 = new Handsontable(container1, {
data: data1,
height: 'auto',
cells(row, col) {
const cellProperties = {};
//This next line is causing the issue.
const data = this.instance.getData();
console.log(data[row][col]);
if (col >= 2) {
cellProperties.readOnly = false;
} else {
cellProperties.readOnly = true;
}
return cellProperties;
},
formulas: {
engine: hyperformulaInstance,
sheetName: 'Sheet1',
},
licenseKey: 'non-commercial-and-evaluation',
});
const container2 = document.querySelector('#example2');
const hot2 = new Handsontable(container2, {
data: data2,
height: 'auto',
formulas: {
engine: hyperformulaInstance,
sheetName: 'Sheet2',
},
licenseKey: 'non-commercial-and-evaluation',
});