언어를 사용하려면 다음과 같이 리소스 js 파일을 가져와야 합니다.
다음 코드를 사용하여 언어 패키지를 전환할 수 있습니다.
다른 언어를 변경하려면 다음 코드를 호출하여 spread 수식을 다시 계산하세요.
언어 패키지 제어
'SUM' 같은 함수 이름 리소스는 프랑스어에서 'SOMME'로 변경됩니다.
'#ALL, #Data' 같은 표 함수 이름 리소스는 프랑스어에서 '#Tout, #Données'로 변경됩니다.
'LENB' 같은 특수 함수 로직 언어에 따라 결과가 다릅니다.
'#NULL!' 같은 CalcError 이름 리소스는 프랑스어에서 '#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("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();
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="ko-kr"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets-resources-ko/dist/gc.spread.sheets.resources.ko.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets-languagepackages/dist/gc.spread.calcengine.languagepackages.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;
}