Handsontable example
by handsoncode
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@14.4/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@14.4/dist/handsontable.full.min.css" />
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="example-basic-multi-sheet-1"></div>
SCSS
h3.demo-preview {
margin-bottom: 0.3rem !important;
padding-top: 0 !important;
margin-top: 0.5rem !important;
}
Babel + JSX
import Handsontable from 'handsontable';
import { HyperFormula } from 'hyperformula';
import 'handsontable/dist/handsontable.full.min.css';
const data1 = [
['10.26', null, 'Sum', '=SUM(A:A)'],
['20.12', null, 'Average', '=AVERAGE(A:A)'],
['30.01', null, 'Median', '=MEDIAN(A:A)'],
['40.29', null, 'MAX', '=MAX(A:A)'],
];
// create an external HyperFormula instance
const hyperformulaInstance = HyperFormula.buildEmpty({
// to use an external HyperFormula instance,
// initialize it with the `'internal-use-in-handsontable'` license key
licenseKey: 'internal-use-in-handsontable',
});
const container1 = document.querySelector('#example-basic-multi-sheet-1');
new Handsontable(container1, {
data: data1,
colHeaders: true,
rowHeaders: true,
height: 'auto',
formulas: {
engine: hyperformulaInstance,
sheetName: 'Sheet1',
},
autoWrapRow: true,
autoWrapCol: true,
columnSorting: {
compareFunctionFactory: function (sortOrder, columnMeta) {
// implement your own comparator
return function (value, nextValue) {
if (value < nextValue) {
return -1;
}
if (value > nextValue) {
return 1;
}
return 0;
};
},
},
licenseKey: 'non-commercial-and-evaluation',
});