SpreadJS supports setting a formula in a specified cell, and you can also add a custom name for this formula.
Use code similar to the following to set a formula for a cell or a range of cells.
sheet.setFormula(1, 1, '=SUM(A1,C3)');
sheet.setArrayFormula(1, 1, 7, 7, '=SUM(A1,C3)');
You can get whether there is a formula in the specified cell by using the following code:
If a formula is lengthy or it is used frequently, you can add a custom name for it to make using it more convenient.
sheet.addCustomName('customName1','=SUM(A1,C3)', 1, 1);
A custom name can be removed from the custom name collection like this:
and you can remove all custom names by using the following method:
Setting a formula via code
Specify the row and column index for the formula cell. Set the row count and column count to specify the number of rows and columns to add the formula to. Add the formula to the Formula box and then click SetFormula to apply the formula.