语言资源

SpreadJS 支持计算引擎包,它提供了使用不同语言公式的方法。

你可以使用以下代码来切换语言包: 当你想更改另一种语言时,请重新计算扩展公式,方法如下: 语言包的影响 函数名资源(如“SUM”)将在法语中更改为“SOMME”。 在法语中,像'#ALL, #Data'这样的表函数名资源将更改为'#Tout, # Donnees '。 像'LENB'这样的特殊函数逻辑在不同的语言中会产生不同的结果。 像'#NULL!'在法语中会显示为'#NOM?'。 像“FALSE”这样的布尔值资源在法语中是“FAUX”。
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss')); initSpread(spread); }; function initSpread(spread) { var sheet = spread.getActiveSheet(); spread.suspendPaint(); sheet.setColumnWidth(0, 20); sheet.setColumnWidth(1, 130); sheet.setColumnWidth(2, 70); sheet.setColumnWidth(3, 70); sheet.setColumnWidth(4, 70); sheet.setColumnWidth(5, 100); var source = [ { Course: "Calculus", Term: 1, Credit: 5, Score: 80, Teacher: "Nancy Feehafer" }, { Course: "P.E.", Term: 1, Credit: 3.5, Score: 85, Teacher: "Andrew Cencini" }, { Course: "Political Economics", Term: 1, Credit: 3.5, Score: 95, Teacher: "Jan Kotas" }, { Course: "Basic of Computer", Term: 1, Credit: 2, Score: 85, Teacher: "Steven Thorpe" }, { Course: "Micro-Economics", Term: 1, Credit: 4, Score: 62, Teacher: "Jan Kotas" }, { Course: "Linear Algebra", Term: 2, Credit: 5, Score: 73, Teacher: "Nancy Feehafer" }, { Course: "Accounting", Term: 2, Credit: 3.5, Score: 86, Teacher: "Nancy Feehafer" }, { Course: "Statistics", Term: 2, Credit: 5, Score: 85, Teacher: "Robert Zare" }, { Course: "Marketing", Term: 2, Credit: 4, Score: 70, Teacher: "Laura Giussani" } ]; sheet.tables.addFromDataSource("Table1", 2, 1, source, GC.Spread.Sheets.Tables.TableThemes.medium7); sheet.setValue(0, 1, "Switch the language and check the SUM formula changes"); sheet.setValue(13, 2, "SUM:"); sheet.setFormula(13, 3, "=SUM(Table1[[#Data], [Credit]])"); sheet.setFormula(13, 4, "=FORMULATEXT(D14)"); sheet.getRange(13, 4, 1, 3) .foreColor("rgb(130, 188, 0)"); sheet.addSpan(13, 4, 1, 3); sheet.setValue(15, 2, "LENB:"); sheet.setFormula(15, 3, '=LENB("中文")'); sheet.setFormula(15, 4, "=FORMULATEXT(D16)"); sheet.getRange(15, 4, 1, 3) .foreColor("rgb(130, 188, 0)"); sheet.addSpan(15, 4, 1, 3); spread.resumePaint(); var selectDiv = document.getElementById('languageSelect'); selectDiv.addEventListener('change',function() { var languageName = this.value; GC.Spread.CalcEngine.LanguagePackages.languagePackages(languageName); sheet.recalcAll(true); }); }
<!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-languagepackages/dist/gc.spread.calcengine.languagepackages.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="ss" class="sample-spreadsheets"></div> <div class="options-container"> <div class="option-row"> Please choose one language from the drop-down list and check the localized function changes. <select id="languageSelect" class="drop-down-list"> <option value="en">English</option> <option value="zh">China</option> <option value="ja">Japan</option> <option value="ko">korea/Korean </option> <option value="fr">French</option> <option value="nl">Dutch</option> <option value="de">German</option> <option value="es">Spanish</option> <option value="pt">Portuguese</option> <option value="ru">Russian</option> <option value="sv">Swedish</option> <option value="it">Italian</option> <option value="da">Danish</option> <option value="pl">Polish</option> <option value="fi">Finnish</option> <option value="no">Norwegian</option> <option value="cs">Czech </option> <option value="hu">Hungarian</option> <option value="tr">Turkish</option> </select> </div> </div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 280px); height:100%; overflow: hidden; float: left; } .options-container { float: right; width: 280px; overflow: auto; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; } .option-row { margin-bottom: 12px; } .drop-down-list { margin-top: 10px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }