Handsontable example

by Aleksandra Maria Budnik

HTML

<script src="https://cdn.jsdelivr.net/npm/handsontable@7.0.2/dist/handsontable.full.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@7.0.2/dist/handsontable.full.min.css">
<div id="example1" class="hot handsontable htRowHeaders htColumnHeaders"></div>

CSS

.handsontable .htCommentCell:after {
  border-top: 6px solid red !important
}

JavaScript

function getData() {
    return [
      ['', 'Tesla', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
      ['2017', 10, 11, 12, 13, 15, 16],
      ['2018', 10, 11, 12, 13, 15, 16],
      ['2019', 10, 11, 12, 13, 15, 16],
      ['2020', 10, 11, 12, 13, 15, 16],
      ['2021', 10, 11, 12, 13, 15, 16]
    ];
  }
  var container = document.getElementById('example1'),
          hot1;
  
  hot1 = new Handsontable(container, {
    data: getData(),
    rowHeaders: true,
    colHeaders: true,
    contextMenu: true,
    comments: true,
    cell: [
      {row: 1, col: 1, comment: {value: 'Some comment'}},
      {row: 2, col: 2, comment: {value: 'More comments'}}
    ]
  });