Language Package

SpreadJS supports calculation engine packages that provide a way to use formulas in different languages.

To use language, you need to import the resource js file as follows: You can use following code to switch language package When you want to change another language, please recalculate the spread formula by calling the following code: Language Package Effection Function name resource like 'SUM' will changes to 'SOMME' in French. Table function name resource like '#ALL, #Data' will changes to '#Tout, #Données' in French. Special function logic like 'LENB' will be different result in different language. CalcError name resource like '#NULL!' will be '#NOM?' in French. Boolean value resource like 'FALSE' will be 'FAUX' in French.
import { Component, NgModule, enableProdMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { SpreadSheetsModule } from '@grapecity/spread-sheets-angular'; import GC from '@grapecity/spread-sheets'; import '@grapecity/spread-sheets-languagepackages'; import './styles.css'; @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { spread: GC.Spread.Sheets.Workbook; hostStyle = { width: 'calc(100% - 280px)', height: '100%', overflow: 'hidden', float: 'left' }; constructor() { } initSpread($event: any) { this.spread = $event.spread; let spread = this.spread; let 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); const 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("SpreadJS")'); 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(); } applyLanguage($event: Event) { let languageName = ($event.target as HTMLSelectElement).value; GC.Spread.CalcEngine.LanguagePackages.languagePackages(languageName); this.spread.sheets[0].recalcAll(true); } } @NgModule({ imports: [BrowserModule, SpreadSheetsModule], declarations: [AppComponent], exports: [AppComponent], bootstrap: [AppComponent] }) export class AppModule {} enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule);
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/angular/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- Polyfills --> <script src="$DEMOROOT$/en/angular/node_modules/core-js/client/shim.min.js"></script> <script src="$DEMOROOT$/en/angular/node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="$DEMOROOT$/en/angular/node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('$DEMOROOT$/en/lib/angular/license.ts'); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html>
<div class="sample-tutorial"> <gc-spread-sheets [hostStyle]="hostStyle" (workbookInitialized)="initSpread($event)"> <gc-worksheet> </gc-worksheet> </gc-spread-sheets> <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" (change)="applyLanguage($event)"> <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>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } .options-container { float: right; width: 280px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row { margin-bottom: 12px; } .drop-down-list { margin-top: 10px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }
(function (global) { System.config({ transpiler: 'ts', typescriptOptions: { tsconfig: true }, meta: { 'typescript': { "exports": "ts" }, '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { 'core-js': 'npm:core-js/client/shim.min.js', 'zone': 'npm:zone.js/dist/zone.min.js', 'rxjs': 'npm:rxjs/bundles/rxjs.umd.min.js', '@angular/core': 'npm:@angular/core/bundles/core.umd.min.js', '@angular/common': 'npm:@angular/common/bundles/common.umd.min.js', '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.min.js', '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.min.js', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js', '@angular/http': 'npm:@angular/http/bundles/http.umd.min.js', '@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.min.js', '@angular/router': 'npm:@angular/router/bundles/router.umd.min.js', '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.min.js', 'jszip': 'npm:jszip/dist/jszip.min.js', 'typescript': 'npm:typescript/lib/typescript.js', 'ts': 'npm:plugin-typescript/lib/plugin.js', 'css': 'npm:systemjs-plugin-css/css.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build':'npm:systemjs-plugin-babel/systemjs-babel-browser.js', '@grapecity/spread-sheets': 'npm:@grapecity/spread-sheets/index.js', '@grapecity/spread-sheets-languagepackages': 'npm:@grapecity/spread-sheets-languagepackages/index.js', '@grapecity/spread-sheets-angular': 'npm:@grapecity/spread-sheets-angular/bundles/grapecity-spread-sheets-angular.umd.js', '@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'ts' }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, } }); })(this);