Spread.Sheets Documentation
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.
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,
   baseRow : number,
   baseColumn : number,
   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.
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 3);
activeSheet.addCustomName("customName1", "=12", 0, 0);
activeSheet.addCustomName("customName2", "Average(20,45)", 0, 0);
activeSheet.addCustomName("customName3", "=$A$1:$C$1");
activeSheet.setFormula(1, 0, "customName1");
activeSheet.setFormula(1, 1, "customName2");
activeSheet.setFormula(1, 2, "sum(customName3)");
 
$("#button1").click(function () {
    var cname = activeSheet.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(activeSheet, expression, 0, 0);
        alert("Name:" + name + ";Expression: =" + expStr);
    }
});
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 3);
activeSheet.addCustomName("customName1", "=12", 0, 0);
activeSheet.addCustomName("customName2", "Average(20,45)", 0, 0);
activeSheet.addCustomName("customName3", "=$A$1:$C$1");
activeSheet.setFormula(1, 0, "customName1");
activeSheet.setFormula(1, 1, "customName2");
activeSheet.setFormula(1, 2, "sum(customName3)");
 
$("#button1").click(function () {
    var cname = activeSheet.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(activeSheet, expression, 0, 0);
        alert("Name:" + name + ";Expression: =" + expStr);
    }
});
See Also

Reference

CalcEngine type

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.