SpreadJS 13
GC.Spread.Sheets Namespace / CalcEngine type / expressionToFormula Method
The context; in general, you should use the active sheet object.
The expression tree.
The base row index of the formula.
The base column index of the formula.
Whether to use the r1c1 reference style.
In This Topic
    expressionToFormula Method
    In This Topic
    Unparse the specified expression tree to formula string.
    Syntax
    var value; // Type: string
    value = GC.Spread.Sheets.CalcEngine.expressionToFormula(context, expression, baseRow, baseColumn, useR1C1);
    function expressionToFormula( 
       context : object,
       expression : Expression,
       (optional) baseRow : number,
       (optional) baseColumn : number,
       (optional) useR1C1 : boolean
    ) : string;

    Parameters

    context
    The context; in general, you should use the active sheet object.
    expression
    The expression tree.
    baseRow
    The base row index of the formula.
    baseColumn
    The base column index of the formula.
    useR1C1
    Whether to use the r1c1 reference style.

    Return Value

    The formula string.
    Example
    The following examples get the formula.
    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.addCustomName("customName1", "=12", 0, 0);
    sheet.addCustomName("customName2", "Average(20,45)", 0, 0);
    sheet.addCustomName("customName3", "=$A$1:$C$1");
    sheet.setFormula(1, 0, "customName1");
    sheet.setFormula(1, 1, "customName2");
    sheet.setFormula(1, 2, "sum(customName3)");
    var cname = sheet.getCustomName("customName2");
    if (cname instanceof GC.Spread.Sheets.NameInfo) {
        // Get CustomName
        var name = cname.getName();
        // Get Expression
        var expression = cname.getExpression();
        // Get Expression String
        var expStr = GC.Spread.Sheets.CalcEngine.expressionToFormula(sheet, expression, 0, 0);
        console.log("Name: " + name + " ; Expression: " + expStr);
    }
    Remarks

    See Also

    Reference

    CalcEngine type