Handsontable example

by Aleksandra Maria Budnik

HTML

<div id="example1"></div>

CSS

.handsontable .red {
  color: red;
}

</style>

<script src="https://cdn.jsdelivr.net/npm/handsontable@7.4.2/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@7.4.2/dist/handsontable.full.min.css">

JavaScript

var example = document.getElementById('example1');
  var hot = new Handsontable(example, {
    data: [
      [-5, 3, -4, 6, 8, 9, -6, 7, 9],
      [5, -3, -4, 6, -8, 9, 6, 7, 9],
      [-5, 3, -4, 6, 8, 9, -6, 7, 9],
      [5, -3, -4, 6, -8, 9, 6, 7, 9],
      [-5, 3, -4, 6, 8, 9, -6, 7, 9],
      [5, -3, -4, 6, -8, 9, 6, 7, 9],
      [-5, 3, -4, 6, 8, 9, -6, 7, 9],
      [5, -3, -4, 6, -8, 9, 6, 7, 9],
      [-5, 3, -4, 6, 8, 9, -6, 7, 9],
      [5, -3, -4, 6, -8, 9, 6, 7, 9],
      [-5, 3, -4, 6, 8, 9, -6, 7, 9],
      [5, -3, -4, 6, -8, 9, 6, 7, 9]
    ],
    rowHeaders: true,
    colHeaders: true
  });
  
  hot.updateSettings({
  	cells: function(row, col){
    	let cp = {}
      if(hot.getDataAtCell(row, col) < 0){
      	cp.className = 'red'
      }
      return cp
    }
  })