Handsontable example

by handsoncode

HTML

<script src="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.css" /> 

<div id="example1" class="hot "></div>
</br>
<div id="example2" class="hot "></div>

JavaScript

const hyperformulaInstance = HyperFormula.buildEmpty({
    licenseKey: 'internal-use-in-handsontable',
});

hyperformulaInstance.addSheet('Sheet1')
hyperformulaInstance.addSheet('Sheet2')

const data1 = [
    ['Sheet 1 Info.', 'This does not work', '=Sheet2!A1'],
];

const data2 = [
    ['Sheet 2 Info.', 'This works', '=Sheet1!A1'],
];

const container1 = document.querySelector('#example1');
const hot1 = Handsontable(container1, {
    data: data1,
    formulas: {
        engine: hyperformulaInstance,
        sheetName: 'Sheet1',
    },
    licenseKey: 'non-commercial-and-evaluation',
});

const container2 = document.querySelector('#example2');
const hot2 = new Handsontable(container2, {
    data: data2,
    formulas: {
        engine: hyperformulaInstance,
        sheetName: 'Sheet2'
    },
    licenseKey: 'non-commercial-and-evaluation',
});