회계 포맷터

SpreadJS는 Excel의 회계 형식을 지원합니다.

표준 회계 형식은 다음과 같이 표시됩니다: '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)' 회계 형식 내의 다른 형식 패턴: 공백 추가 ('_')\: 문자의 너비인 공백을 숫자 형식으로 만들려면 밑줄 문자('_') 뒤에 사용할 문자를 붙여 포함합니다. 반복 문자 ('*')\: 형식에서 다음 문자를 반복하여 열 너비를 채우려면 숫자 형식에 별표(*)를 포함합니다. 천 단위 구분 기호 및 눈금 (',')\: 숫자에 천 단위 구분 기호를 표시합니다. Spread는 형식에 숫자 기호(#) 또는 0으로 묶인 쉼표가 있으면 쉼표로 천 단위를 구분합니다. 자리 표시자 뒤에 오는 쉼표는 1,000 기준으로 숫자 크기를 조정합니다. 예를 들어, 형식이 #.0,,이고 셀에 12,200,000을 입력하면 숫자 12.200.0이 표시됩니다. 백분율 ('%')\: 숫자를 백분율로 표시하려면(예: 0.08을 8% 또는 2.8을 280%로 표시하려면) 숫자 형식에 백분율 기호(%)를 포함합니다. 예를 들어, (2,2)의 수를 백분율로 표시하려면 10000의 백분율로 표시할 수도 있습니다. 디지털 자리 표시자 ('?')\: 숫자 값에 디지털 자리 표시자를 추가하려면 0과 동일한 규칙을 따르는 물음표 기호(?)를 사용할 수 있습니다. 또한 Spread는 소수점의 오른쪽 또는 왼쪽에 의미 없는 0을 위한 공간을 추가합니다.
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> <gc-worksheet :autoGenerateColumns='autoGenerateColumns'> </gc-worksheet> </gc-spread-sheets> </div> </template> <script> import Vue from "vue"; import GC from '@mescius/spread-sheets'; import '@mescius/spread-sheets-resources-ko'; import '@mescius/spread-sheets-vue' GC.Spread.Common.CultureManager.culture("ko-kr"); import './styles.css'; let App = Vue.extend({ name: "app", data: function() { return { autoGenerateColumns: true, spread: null }; }, methods:{ initSpread: function (spread) { this.spread = spread; spread.suspendPaint(); let sheet = spread.getSheet(0); sheet.setColumnWidth(0, 150); sheet.setColumnWidth(1, 200); sheet.setColumnWidth(2, 150); sheet.setColumnWidth(3, 150); sheet.getRange(-1, 1, 200, 1).hAlign(1); //set standard accounting formatter this.initStandardAccountingFormat(sheet); //set repeat chartacters formatter this.initRepeatCharacters(sheet); //set placeholder formatter this.initPlaceholder(sheet); //set text formatter this.initText(sheet); //set thousands separator formatter this.thousandsSeparator(sheet); // set percentages formatter this.initPercentages(sheet); //set digital placeholder formatter this.initDigitalPlaceholder(sheet); spread.resumePaint(); }, inintHeaderStyle: function(sheet, rowIndex) { sheet.setRowHeight(rowIndex, 30); sheet.addSpan(rowIndex, 0, 1, 4); sheet.getRange(rowIndex, 0, 1, 4).backColor('grey').foreColor('white').vAlign(1); }, initStandardAccountingFormat: function(sheet) { this.inintHeaderStyle(sheet, 1); sheet.setValue(1, 0, 'Standard Accounting Format : _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)'); sheet.setValue(2, 0, 'Value'); sheet.setValue(3, 0, 12); sheet.setValue(4, 0, -12); sheet.setValue(5, 0, 0); sheet.setValue(6, 0, 'Text'); sheet.setValue(2, 2, 'Formatted Result'); sheet.getRange(3, 2, 4, 1).formatter('_($* #,##0.000_);_($* (#,##0.000);_($* "-"??_);_(@_)'); sheet.setValue(3, 2, 12); sheet.setValue(4, 2, -12); sheet.setValue(5, 2, 0); sheet.setValue(6, 2, 'Text'); }, initRepeatCharacters: function(sheet) { let rowIndex = 8; this.inintHeaderStyle(sheet, rowIndex); sheet.setValue(rowIndex, 0, 'Repeat Characters : *'); rowIndex++; sheet.setValue(rowIndex, 0, 'Value'); sheet.setValue(rowIndex, 1, 'Format'); sheet.setValue(rowIndex, 2, 'Formatted Result'); rowIndex++; sheet.setValue(rowIndex, 0, 'Sign'); sheet.setValue(rowIndex, 1, '@*.'); sheet.setValue(rowIndex, 2, 'Sign'); sheet.setFormatter(rowIndex, 2, '@*.'); rowIndex++; sheet.setValue(rowIndex, 0, 'Sign'); sheet.setValue(rowIndex, 1, '*.@'); sheet.setValue(rowIndex, 2, 'Sign'); sheet.setFormatter(rowIndex, 2, '*.@'); rowIndex++; sheet.setValue(rowIndex, 0, 12.34); sheet.setValue(rowIndex, 1, '$* #.##'); sheet.setValue(rowIndex, 2, 12.34); sheet.setFormatter(rowIndex, 2, '$* #.##'); rowIndex++; sheet.setValue(rowIndex, 0, 12.34); sheet.setValue(rowIndex, 1, '$#.##*_'); sheet.setValue(rowIndex, 2, 12.34); sheet.setFormatter(rowIndex, 2, '$#.##*_'); }, initPlaceholder: function(sheet) { let rowIndex = 15; this.inintHeaderStyle(sheet, rowIndex); sheet.setValue(rowIndex, 0, "Add Space(use the follow char's width as a space ) : _"); rowIndex++; sheet.setValue(rowIndex, 0, 'Value'); sheet.setValue(rowIndex, 1, 'Format'); sheet.setValue(rowIndex, 2, 'Formatted Result'); rowIndex++; sheet.setValue(rowIndex, 0, 'Sign'); sheet.setValue(rowIndex, 1, '_W@'); sheet.setValue(rowIndex, 2, 'Sign'); sheet.setFormatter(rowIndex, 2, '_W@'); rowIndex++; sheet.setValue(rowIndex, 0, 'Sign'); sheet.setValue(rowIndex, 1, '_.@'); sheet.setValue(rowIndex, 2, 'Sign'); sheet.setFormatter(rowIndex, 2, '_.@'); rowIndex++; sheet.setValue(rowIndex, 0, 12); sheet.setValue(rowIndex, 1, '#_W'); sheet.setValue(rowIndex, 2, 12); sheet.setFormatter(rowIndex, 2, '#_W'); rowIndex++; sheet.setValue(rowIndex, 0, 12); sheet.setValue(rowIndex, 1, '#_.'); sheet.setValue(rowIndex, 2, 12); sheet.setFormatter(rowIndex, 2, '#_.'); }, initText: function(sheet) { let rowIndex = 22; this.inintHeaderStyle(sheet, rowIndex); sheet.setValue(rowIndex, 0, "Text/Label : \"\"& \\"); rowIndex++; sheet.setValue(rowIndex, 0, 'Value'); sheet.setValue(rowIndex, 1, 'Format'); sheet.setValue(rowIndex, 2, 'Formatted Result'); rowIndex++; sheet.setValue(rowIndex, 0, 15); sheet.setValue(rowIndex, 1, '#,##0 "Km"'); sheet.setValue(rowIndex, 2, 15); sheet.setFormatter(rowIndex, 2, '#,##0 "Km"'); rowIndex++; sheet.setValue(rowIndex, 0, 2573); sheet.setValue(rowIndex, 1, '#,##0 "Over";#,##0 "Under"'); sheet.setValue(rowIndex, 2, 2573); sheet.setFormatter(rowIndex, 2, '#,##0 "Over";#,##0 "Under"'); rowIndex++; sheet.setValue(rowIndex, 0, -2573); sheet.setValue(rowIndex, 1, '#,##0 "Over";#,##0 "Under"'); sheet.setValue(rowIndex, 2, -2573); sheet.setFormatter(rowIndex, 2, '#,##0 "Over";#,##0 "Under"'); rowIndex++; sheet.setValue(rowIndex, 0, 'ExcelRocks'); sheet.setValue(rowIndex, 1, '\\a@'); sheet.setValue(rowIndex, 2, 'ExcelRocks'); sheet.setFormatter(rowIndex, 2, '\\a@'); }, thousandsSeparator: function(sheet) { let rowIndex = 29; this.inintHeaderStyle(sheet, rowIndex); sheet.setValue(rowIndex, 0, 'Thousands Separator (comma) and Scaling : ,'); rowIndex++; sheet.setValue(rowIndex, 0, 'Value'); sheet.setValue(rowIndex, 1, 'Format'); sheet.setValue(rowIndex, 2, 'Formatted Result'); rowIndex++; sheet.setValue(rowIndex, 0, 12000); sheet.setValue(rowIndex, 1, '#,###'); sheet.setValue(rowIndex, 2, 12000); sheet.setFormatter(rowIndex, 2, '#,###'); rowIndex++; sheet.setValue(rowIndex, 0, 12000000); sheet.setValue(rowIndex, 1, '#,###'); sheet.setValue(rowIndex, 2, 12000000); sheet.setFormatter(rowIndex, 2, '#,###'); rowIndex++; sheet.setValue(rowIndex, 0, 12000); sheet.setValue(rowIndex, 1, '#,'); sheet.setValue(rowIndex, 2, 12000); sheet.setFormatter(rowIndex, 2, '#,'); rowIndex++; sheet.setValue(rowIndex, 0, 12000000); sheet.setValue(rowIndex, 1, '#,,'); sheet.setValue(rowIndex, 2, 12000000); sheet.setFormatter(rowIndex, 2, '#,,'); rowIndex++; sheet.setValue(rowIndex, 0, 12000); sheet.setValue(rowIndex, 1, '#,\\K'); sheet.setValue(rowIndex, 2, 12000); sheet.setFormatter(rowIndex, 2, '#,\\K'); rowIndex++; sheet.setValue(rowIndex, 0, 12000000); sheet.setValue(rowIndex, 1, '#,###,\\K'); sheet.setValue(rowIndex, 2, 12000000); sheet.setFormatter(rowIndex, 2, '#,###,\\K'); }, initPercentages: function(sheet) { let rowIndex = 38; this.inintHeaderStyle(sheet, rowIndex); sheet.setValue(rowIndex, 0, 'Percentages : %'); rowIndex++; sheet.setValue(rowIndex, 0, 'Value'); sheet.setValue(rowIndex, 1, 'Format'); sheet.setValue(rowIndex, 2, 'Formatted Result'); rowIndex++; sheet.setValue(rowIndex, 0, 0.09); sheet.setValue(rowIndex, 1, '0%'); sheet.setValue(rowIndex, 2, 0.09); sheet.setFormatter(rowIndex, 2, '0%'); rowIndex++; sheet.setValue(rowIndex, 0, 0.952); sheet.setValue(rowIndex, 1, '0.0%'); sheet.setValue(rowIndex, 2, 0.952); sheet.setFormatter(rowIndex, 2, '0.0%'); rowIndex++; sheet.setValue(rowIndex, 0, 1); sheet.setValue(rowIndex, 1, '#%'); sheet.setValue(rowIndex, 2, 1); sheet.setFormatter(rowIndex, 2, '#%'); rowIndex++; sheet.setValue(rowIndex, 0, 1); sheet.setValue(rowIndex, 1, '#%%'); sheet.setValue(rowIndex, 2, 1); sheet.setFormatter(rowIndex, 2, '#%%'); }, initDigitalPlaceholder: function(sheet) { let rowIndex = 45; this.inintHeaderStyle(sheet, rowIndex); sheet.setValue(rowIndex, 0, 'Digital Placeholder : #, 0 and ?'); rowIndex++; sheet.setValue(rowIndex, 0, 'Value'); sheet.setValue(rowIndex, 1, 'Format'); sheet.setValue(rowIndex, 2, 'Formatted Result'); rowIndex++; sheet.setValue(rowIndex, 0, 123.456); sheet.setValue(rowIndex, 1, '#.####'); sheet.setValue(rowIndex, 2, 123.456); sheet.setFormatter(rowIndex, 2, '#.####'); rowIndex++; sheet.setValue(rowIndex, 0, 123.456); sheet.setValue(rowIndex, 1, '0.0000'); sheet.setValue(rowIndex, 2, 123.456); sheet.setFormatter(rowIndex, 2, '0.0000'); rowIndex++; sheet.setValue(rowIndex, 0, 123.456); sheet.setValue(rowIndex, 1, '?.????'); sheet.setValue(rowIndex, 2, 123.456); sheet.setFormatter(rowIndex, 2, '?.????'); rowIndex++; sheet.setValue(rowIndex, 0, 123.456); sheet.setValue(rowIndex, 1, '####.###'); sheet.setValue(rowIndex, 2, 123.456); sheet.setFormatter(rowIndex, 2, '#####.###'); rowIndex++; sheet.setValue(rowIndex, 0, 123.456); sheet.setValue(rowIndex, 1, '0000.000'); sheet.setValue(rowIndex, 2, 123.456); sheet.setFormatter(rowIndex, 2, '0000.000'); rowIndex++; sheet.setValue(rowIndex, 0, 123.456); sheet.setValue(rowIndex, 1, '????.???'); sheet.setValue(rowIndex, 2, 123.456); sheet.setFormatter(rowIndex, 2, '????.???'); rowIndex++; rowIndex++; sheet.setValue(rowIndex, 0, 1.1); sheet.setValue(rowIndex, 1, '#.???'); sheet.setValue(rowIndex, 2, 1.1); sheet.setFormatter(rowIndex, 2, '#.???'); rowIndex++; sheet.setValue(rowIndex, 0, 11.12); sheet.setValue(rowIndex, 1, '#.???'); sheet.setValue(rowIndex, 2, 11.12); sheet.setFormatter(rowIndex, 2, '#.???'); rowIndex++; sheet.setValue(rowIndex, 0, 111.123); sheet.setValue(rowIndex, 1, '#.???'); sheet.setValue(rowIndex, 2, 111.123); sheet.setFormatter(rowIndex, 2, '#.???'); } }, }); new Vue({ render: h => h(App) }).$mount('#app'); </script>
<!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$/ko/vue/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- SystemJS --> <script src="$DEMOROOT$/ko/vue/node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); System.import('$DEMOROOT$/ko/lib/vue/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; } z .options-container { float: right; width: 280px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row { font-size: 14px; padding: 5px; margin-top: 10px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { height: 100% }
(function (global) { System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, meta: { '*.css': { loader: 'css' }, '*.vue': { loader: 'vue-loader' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js', '@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js', 'jszip': 'npm:jszip/dist/jszip.js', 'css': 'npm:systemjs-plugin-css/css.js', 'vue': 'npm:vue/dist/vue.min.js', 'vue-loader': 'npm:systemjs-vue-browser/index.js', 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build':'npm:systemjs-plugin-babel/systemjs-babel-browser.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'js' }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' } } }); })(this);