SpreadJS 13
GC.Spread.Sheets Namespace / CellRange type / formula Method
The cell formula.
In This Topic
    formula Method
    In This Topic
    Gets or sets the formula for the cell.
    Syntax
    var instance = new GC.Spread.Sheets.CellRange(sheet, row, col, rowCount, colCount, sheetArea);
    var returnValue; // Type: any
    returnValue = instance.formula(value);
    function formula( 
       (optional) value : string
    ) : any;

    Parameters

    value
    The cell formula.

    Return Value

    If no value is set, returns the cell formula; otherwise, returns the cell.
    Example
    The following examples set the formula method.
    activeSheet.setValue(0,0,1);
    activeSheet.setValue(0,1,2);
    activeSheet.setValue(0,2,10);
    activeSheet.getCell(1,1).formula("=SUM(A1:C1)");
    var formula = activeSheet.getFormula(1,1);
    alert(formula);
    activeSheet.setValue(0, 0, 'abc');
    activeSheet.setValue(1, 0, 'ac');
    activeSheet.setValue(2, 0, 'a*');
     
    activeSheet.getCell(0, 1).formula('COUNTIF(A1:A3,"a*")');  //start with a
    activeSheet.getCell(1, 1).formula('COUNTIF(A1:A3,"a?")');  //"a" and only one other character
    activeSheet.getCell(2, 1).formula('COUNTIF(A1:A3,"a~*")'); // should be "a*"
    activeSheet.getCell(0,2).formula("DATEDIF(DATE(2003,1,1),DATE(2016,1,1),\"Y\")");
    Remarks
    The default value is null.
    See Also