Handsontable example
by handsoncode
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@15.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@15.1/styles/handsontable.min.css" />
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@15.1/styles/ht-theme-main.css" />
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@15.1/styles/ht-theme-horizon.css" />
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="example1" class="hot ht-theme-main " ></div>
Babel + JSX
import Handsontable from 'handsontable';
import 'handsontable/styles/handsontable.css';
import 'handsontable/styles/ht-theme-main.css';
// generate an array of arrays with dummy data
const data = new Array(100) // number of rows
.fill(null)
.map((_, row) =>
new Array(50) // number of columns
.fill(null)
.map((_, column) => `${row}, ${column}`)
);
const container = document.querySelector('#example1');
new Handsontable(container, {
data,
height: 320,
colWidths: 50,
rowHeaders: true,
colHeaders: true,
contextMenu: true,
afterChange: function(changes, src){
if(src === 'loadData'){
console.log(this)
this.selectCells([[1, 1, 2, 2], [3, 3], [6, 2, 0, 2]]);
}
},
autoWrapRow: true,
autoWrapCol: true,
licenseKey: 'non-commercial-and-evaluation',
});