SpreadJS Documentation
formula Method
The cell formula.
Gets or sets the formula for the cell.
Syntax
var instance = new GcSpread.Sheets.Cell(sheet, row, col, sheetArea);
var returnValue; // Type: string
returnValue = instance.formula(value);
function formula( 
   value : string
) : string;

Parameters

value
The cell formula.

Return Value

The cell formula.
Example
This example uses 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

Reference

Cell type
Using Formulas

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.