单引号前缀

Spread.Sheets支持单引号前缀功能,就像Excel那样。

当你输入的值带有单引号前缀',输入的值会被转换并存储为字符串。
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 1}); initFunction(spread); }; function initFunction(spread) { var fbx = new GC.Spread.Sheets.FormulaTextBox.FormulaTextBox(document.getElementById('formulaBar')); fbx.workbook(spread); var sheet = spread.getActiveSheet(); sheet.suspendPaint(); sheet.setColumnWidth(1, 100); sheet.setColumnWidth(2, 300); sheet.setValue(1, 0, 'Sample:'); sheet.setValue(2, 1, 'Normal'); sheet.setValue(3, 1, 'Quote Prefix'); sheet.setValue(4, 1, 'Normal'); sheet.setValue(5, 1, 'Quote Prefix'); spread.commandManager().execute({ cmd: "editCell", sheetName: "Sheet1", row: 2, col: 2, newValue: "12" }); spread.commandManager().execute({ cmd: "editCell", sheetName: "Sheet1", row: 3, col: 2, newValue: "'12" }); spread.commandManager().execute({ cmd: "editCell", sheetName: "Sheet1", row: 4, col: 2, newValue: "4/2/2020 13:39:48" }); spread.commandManager().execute({ cmd: "editCell", sheetName: "Sheet1", row: 5, col: 2, newValue: "'4/2/2020 13:39:48" }); sheet.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 id="formulaBar" contenteditable="true" spellcheck="false" style="border: 1px solid grey; height: 21px; width: 100%; overflow: hidden; font-size: 13px; font-family: arial, sans, sans-serif; margin-bottom: 3px; padding-top: 3px; padding-bottom: 3px"></div> <div id="ss" style="width:100%; height:100%; border: 1px solid gray;"></div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }