You can put formulas in cells.

This example sets formulas in cells.
| JavaScript |
Copy Code
|
|---|---|
window.onload = function() { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount:3}); var activeSheet = spread.getActiveSheet(); activeSheet.setRowCount(5); activeSheet.setColumnCount(2); activeSheet.getRange(-1, 1, -1, 1) .backColor("lightYellow") .width(120); activeSheet.setValue(0, 0, 10); activeSheet.setValue(1, 0, 20); activeSheet.setValue(2, 0, 30); activeSheet.setValue(3, 0, 40); activeSheet.setValue(4, 0, 50); // Set SUM function (Sum of all parameter values). activeSheet.setFormula(0, 1, "SUM(A1:A5)"); // Set PRODUCT function (Product of all parameter values). activeSheet.setFormula(1, 1, "PRODUCT(A1:A5)"); // Set AVERAGE function (Average of all parameter values). activeSheet.setFormula(2, 1, "AVERAGE(A1:A5)"); // Set the sum of cell(0,0) and cell(4,0). activeSheet.setFormula(3, 1, "A1 + A5"); /* Multiply cell(0,0) by 2 if the value in this cell is greater than 10, otherwise multiply it by 3. */ activeSheet.setFormula(4, 1, "IF(A1>10, A1*2, A1*3)"); } |
|