基本应用

当你输入公式时,你可能会忘记有效的函数名称。因此,当你输入一个公式时,Spread Sheets 会提供一个公式列表来显示函数的描述。当公式列表显示时,按下 Tab 键,公式的名称会进行自动补全。

如果你在公式中输入一个区域,区域指示器也会显示出来。你可以使用鼠标来选择一个区域。 你可以使用Function类来添加自定义的函数。例如: 你还可以获取自定义函数的描述: 您可以通过修改 CSS 定义来更改跨工作表的单元格公式文本框及其弹出元素:
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 2}); initSpread(spread); }; function initSpread(spread) { var spreadNS = GC.Spread.Sheets; var fbx = new spreadNS.FormulaTextBox.FormulaTextBox(document.getElementById('formulaBar')); fbx.workbook(spread); spread.suspendPaint(); var sheet2 = spread.sheets[1]; sheet2.setArray(0, 0, [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); var sheet = spread.sheets[0]; sheet.options.allowCellOverflow = true; sheet.setValue(1, 2, "A helpful text box is displayed when typing any formula in a cell or the area above the sheet."); sheet.setValue(2, 2, "For example: =sum(1,2,3)"); for (var i = 5; i < 35; i++) { for (var j = 1; j < 15; j++) { sheet.setValue(i, j, i * j); } } // used to help show table support feature sheet.tables.add("Table1", 4, 7, 5, 4); for (var c = 7; c <= 10; c++) { sheet.setColumnWidth(c, 90); } sheet.setFormula(3, 0, "Table1[[#Headers],[Column2]]"); // used to help show custom name support feature sheet.addCustomName("RangeB6C9", "$B$6:$C$9", 0, 0); sheet.addCustomName("Range2", "SUM($C$11:$D$14)", 0, 0); sheet.setFormula(4, 0, "AVERAGE(RangeB6C9)"); // used to help show multi supported reference types var formula = "SUM(B6:C9,E6:F9,Table1[#Data],Range2,F11:J14,D16:I17)"; sheet.setActiveCell(1, 0); sheet.getCell(1, 0).formula(formula); fbx.text("=" + formula); // used to help show cross sheet reference sheet.setFormula(5, 0, "SUM(sheet2!A1:C3)"); sheet.getRange(1, 0, 5, 1).foreColor("green"); spread.resumePaint(); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="zh-cn" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div class="demo-options"> <div class="option-row"> <div id="formulaBar" contenteditable="true" spellcheck="false" style="font-family: Calibri;border: 1px solid #808080;width:100%;box-sizing: border-box;"></div> </div> </div> <div id="ss" style="width:100%; height: calc(100% - 20px)"></div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; margin: 0; top: 0; bottom: 0; left: 0; right: 0; } .gc-across-sheet-ftb { z-index: -1 !important; } .gc-across-sheet-func-popup { z-index: -1 !important; }