SpreadJS Documentation > Sample Code > Sample Code for Formulas > Using Cross Sheet References |
You can reference other sheets in a formula.
The following image displays the first sheet from the example.
The following image displays the second sheet from the example.
This example uses cross-sheet references.
JavaScript |
Copy Code
|
---|---|
$(document).ready(function () { var spread = new GcSpread.Sheets.Spread($("#ss").get(0),{sheetCount:3}); var sheet1 = spread.getSheet(0), sheet2 = spread.getSheet(1); sheet1.setName("Sheet1"); sheet2.setName("Sheet2"); sheet1.setValue(0, 0, 1000); sheet1.setValue(1, 0, 2000); sheet1.setValue(2, 0, 3000); sheet1.setValue(3, 0, 4000); sheet1.getCells(0, 0, 3, 0).backColor("lightPink"); sheet2.setValue(0, 0, 5000); sheet2.getCells(0, 0, 0, 0).backColor("lightCyan"); //Set a sum formula of "Sheet1: total of cell(0,0) to cell(3,0)" and "Sheet2: cell(0,0)". sheet2.setFormula(1, 1, "SUM(Sheet1!A1:A4) + Sheet2!A1"); sheet2.getCells(1, 1, 1, 1).backColor("lemonChiffon"); }); |