SpreadJS Documentation
Convert Formula To Expression
SpreadJS Documentation > Sample Code > Sample Code for Cell References > Convert Formula To Expression

You can convert a formula to an expression using the formulaToExpression() method as shown in the code snippet shared below. 


JavaScript
Copy Code
var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
sheet = spread.getSheet(0);
sheet.setValue(0, 0, 1);
sheet.setValue(0, 1, 2);
sheet.setValue(0, 2, 3);
sheet.getCell(4, 4).formula("=SUM(A1:C1)");
var formula = sheet.getFormula(4, 4);
var expression = GC.Spread.Sheets.CalcEngine.formulaToExpression(sheet, formula, 0, 0);
console.log("Function Name is: " + expression.functionName);