Creating custom formulas

You can declare custom javascript methods and use in your tables as the example below.



Source code

<html>
<script src="https://jexcel.net/v5/jexcel.js"></script>
<script src="https://jexcel.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jexcel.net/v5/jexcel.css" type="text/css" />
<link rel="stylesheet" href="https://jexcel.net/v5/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<script>
var COLORIZE = function(v) {
    v = '<span style="color:' + v + '">' + v.toUpperCase() + '</span>';
    return v;
}

var data = [
    [ 'red', '=COLORIZE(A1)' ],
    [ 'green', '=COLORIZE(A2)' ],
    [ 'blue', '=COLORIZE(A3)' ],
];

jexcel(document.getElementById('spreadsheet'), {
    data:data,
    columns: [
        { type: 'text', width:'300' },
        { type: 'text', width:'200' },
    ],
    license: '39130-64ebc-bd98e-26bc4',
});
</script>
</html>