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" />
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="example1" class="hot "></div>
Babel + JSX
import Handsontable from 'handsontable';
import 'handsontable/dist/handsontable.full.min.css';
// Initial data
const data = new Array(10)
.fill()
.map((_, row) => new Array(5)
.fill()
.map((_, column) => `${row * column + 1}`)
);
// Mapping data to have `=A1+B1` in the last column
const mappedData = data.map((row, rowIndex) => {
// Assuming A1, B1 are the first two columns in each row
const formula = `=${String.fromCharCode(65)}${rowIndex + 1}+${String.fromCharCode(66)}${rowIndex + 1}`;
return [...row.slice(0, -1), formula];
});
console.log(mappedData);
const container = document.querySelector('#example1');
const hot = new Handsontable(container, {
data: mappedData,
height: 500,
colWidths: 47,
rowHeaders: true,
colHeaders: true,
contextMenu: true,
formulas: {
engine: HyperFormula
},
autoWrapRow: true,
autoWrapCol: true,
licenseKey: 'non-commercial-and-evaluation'
});