jspreadsheet / pro

Jspreadsheet Pro | The javascript spreadsheet
https://jspreadsheet.com/
15 stars 1 forks source link

set custom class to the cell #339

Closed Rajnish710 closed 2 months ago

Rajnish710 commented 2 months ago

Can I assign a custom class to a specific cell like we use setStyle?

hodeware commented 2 months ago

If the cell is visible, you can do: instance.records[y][x].element.classList.add('yourClass');

Via event:

jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{ minDimensions: [6,6]}],
    oncreatecell: function(worksheet, cell, x, y, value) {
        if (x === 0 && y === 0) {
              cell.classList.add('yourClass');
        }
    }
});

Via validations: You can use format type.


{
            range: 'Sheet1!B1:B3',
            action: "format",
            criteria: "<",
            type: "number",
            value: [500],
            format: { color: '#ff0000' },
            className: 'yourClass' // add this class if the condition is match
}
``