Handsontable example

by handsoncode

HTML

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

CSS

body {
  background: white;
  margin: 0;
  padding: 0;
}

JavaScript

document.addEventListener("DOMContentLoaded", function() {

  var
    example = document.getElementById('example'),
    hot;

  hot = new Handsontable(example, {
    data: Handsontable.helper.createSpreadsheetData(10, 6),
    colWidths: 107,
    width: 620,
    colHeaders: true,
    contextMenu: true,
    licenseKey: 'non-commercial-and-evaluation',
  });

  hot.updateSettings({
    contextMenu: {
      items: {
        "export": {
          name: 'Export to CSV',
          callback: function(key, options) {
            hot.getPlugin('exportFile').downloadFile('csv', {
      filename: 'MyFile'
    });
          }
        }
      }
    }
  });

});