Handsontable example
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@16.2/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@16.2/styles/handsontable.min.css" />
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@16.2/styles/ht-theme-main.css" />
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="example1" class="hot"></div>
Babel + JSX
import Handsontable from 'handsontable/base';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/styles/handsontable.css';
import 'handsontable/styles/ht-theme-main.css';
// Register all Handsontable's modules.
registerAllModules();
const container = document.querySelector('#example1');
new Handsontable(container, {
themeName: 'ht-theme-main',
licenseKey: 'non-commercial-and-evaluation',
data: [
['Mercedes', 'A 160', '14/01/2021', 6999.95],
['Citroen', 'C4 Coupe', '10/01/2022', 8330],
['Audi', 'A4 Avant', '11/07/2023', 33900],
['Opel', 'Astra', '02/02/2021', 7000],
['BMW', '320i Coupe', '24/04/2022', 30500],
],
colHeaders: ['Car', 'Model', 'Registration date', 'Price'],
height: 'auto',
columns: [
{
type: 'text',
},
{
// 2nd cell is simple text, no special options here
},
{
type: 'date',
dateFormat: 'DD/MM/YYYY',
correctFormat: true,
defaultDate: '01/01/2020',
// datePicker additional options
// (see https://github.com/dbushell/Pikaday#configuration)
datePickerConfig: {
// First day of the week (0: Sunday, 1: Monday, etc)
firstDay: 0,
showWeekNumber: true,
disableDayFn(date) {
// Disable Sunday and Saturday
return date.getDay() === 0 || date.getDay() === 6;
},
},
},
{
type: 'numeric',
numericFormat: {
pattern: '$0,0.00',
},
},
],
autoWrapRow: true,
autoWrapCol: true,
});