SpreadJS製品ヘルプ
formula メソッド
GC.Spread.Sheets 名前空間 > CellRange タイプ : formula メソッド
セル数式。
セルの数式を取得または設定します。
シンタックス
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;

パラメータ

value
セル数式。

戻り値の型

値が設定されていない場合は、セルの数式を返します。値が設定されている場合は、セルを返します。
使用例
次のサンプルコードは、formulaメソッドを設定します。
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\")");
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\")");
解説
デフォルト値はnullです。
関連トピック

参照

CellRange タイプ
数式
数式