GcNumber型セル

GcNumber型セルは、ドロップダウンする数値パッドを備え、表示書式、入力時の書式として桁区切りや小数点、通貨記号、負号、漢数字などの設定が可能です。

GcNumber型セルを作成するには、次の例のようなコードを使用します。 GcNumber型セルの主なオプションは以下の通りです。オプションの完全なリストと機能の詳細については、InputManJSのAPIリファレンスやデモアプリケーションを参照してください。 formatDigit: 入力時の数値の桁数、および小数点と桁区切り記号の位置を設定します。 positivePrefix: 入力時の正の数値の前に配置する通貨記号や負号などのリテラル文字を設定します。 positiveSuffix: 入力時の正の数値の後に配置するリテラル文字を設定します。 negativePrefix: 入力時の負の数値の前に配置する通貨記号や負号などのリテラル文字を設定します。 negativeSuffix: 入力時の負の数値の後に配置するリテラル文字を設定します。 displayType: セルの値に入力書式と同じ文字列を設定する場合は'text'を、数値を設定する場合は'value'を設定します。'value'を設定した場合、セルのフォーマッタで指定された書式で表示されます。 showSpinButton: スピンボタンを表示します。 spinOnKeys: 上下キーの操作を有効にします。 spinWrap: 値が最大値に達した場合は最小値に、最小値に達した場合は最大値に、それぞれ自動的に値を変更します。 showNumericPad: ドロップダウンに数値パッドを追加します。 autoDropDown: 入力時にドロップダウンを自動的に表示するかどうかを設定します。 minDate: 入力可能な数値の最小値を設定します。 maxDate: 入力可能な数値の最大値を設定します。 watermarkNullText: 未入力のときの代替テキストを設定します。
import { Component, NgModule, enableProdMode } from '@angular/core'; import { bootstrapApplication, BrowserModule } from '@angular/platform-browser'; import '@mescius/spread-sheets-resources-ja'; import { FormsModule } from '@angular/forms'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { SpreadSheetsModule } from '@mescius/spread-sheets-angular'; import { InputManModule } from "@mescius/inputman.angular"; import * as GC from '@mescius/inputman'; import GC2 from '@mescius/spread-sheets'; import { GcNumberCellType } from '@mescius/spread-sheets-inputmancelltype' import '@mescius/inputman/CSS/gc.inputman-js.css'; import './styles.css'; GC2.Spread.Common.CultureManager.culture("ja-jp"); @Component({ standalone: true, imports: [BrowserModule, SpreadSheetsModule, FormsModule, InputManModule], selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { ngOnInit(): void { GC.InputMan.appearanceStyle = GC.InputMan.AppearanceStyle.Modern; } hostStyle = { width: 'calc(100% - 280px)', height: '100%', overflow: 'hidden', float: 'left' }; formatPatterns = ['¥#####', '税込 ##,##0円', '##,##0.00'] formatPattern = 0; spread: GC2.Spread.Sheets.Workbook; sheet: any = null; displayTypeValue: boolean = false; showSpinButton: boolean = false; showNumericPad: boolean = false; watermarkNullText: boolean = false; maxValue: number = 99999; minValue: number = -99999; initSpread($event: any) { this.spread = $event.spread; this.sheet = this.spread.getActiveSheet(); this.sheet.suspendPaint(); this.sheet.setColumnWidth(0, 100); this.sheet.setColumnWidth(1, 150); this.sheet.setColumnWidth(2, 120); this.sheet.setColumnWidth(3, 120); this.sheet.setColumnWidth(4, 120); this.sheet.setColumnWidth(5, 120); this.sheet.setColumnWidth(6, 100); this.sheet.setRowHeight(2, 30); this.sheet.setText(0, 1, 'B3セルにGcNumber型セルが設定されています。'); this.sheet.setText(1, 1, ' ↓'); this.sheet .getRange(2, 1, 1, 1) .vAlign(GC2.Spread.Sheets.VerticalAlign.center) .setBorder(new GC2.Spread.Sheets.LineBorder('orange', GC2.Spread.Sheets.LineStyle.medium), { outline: true }); this.sheet.setText(4, 0, '右側のパネルの書式には、それぞれ以下のような書式が設定されています。'); this.sheet.setText(6, 1, '数値書式'); this.sheet.setText(6, 2, '正数の接頭書式'); this.sheet.setText(6, 3, '正数の接尾書式'); this.sheet.setText(6, 4, '負数の接頭書式'); this.sheet.setText(6, 5, '負数の接尾書式'); this.sheet.setText(6, 6, '通貨記号'); this.sheet.setText(7, 0, '¥##### '); this.sheet.setText(8, 0, '税込 ##,##0円 '); this.sheet.setText(9, 0, '##,##0.00 '); this.sheet .getRange(7, 0, 3, 1, GC2.Spread.Sheets.SheetArea.viewport).hAlign(GC2.Spread.Sheets.HorizontalAlign.right); this.sheet.setText(7, 1, ' #####'); this.sheet.setText(7, 2, ' $'); this.sheet.setText(7, 3, ''); this.sheet.setText(7, 4, ' -$'); this.sheet.setText(7, 5, ''); this.sheet.setText(7, 6, ' ¥'); this.sheet.setText(8, 1, ' ##,##0'); this.sheet.setText(8, 2, ' 税込 '); this.sheet.setText(8, 3, ' 円'); this.sheet.setText(8, 4, ' 税込 ▲'); this.sheet.setText(8, 5, ' 円'); this.sheet.setText(8, 6, ''); this.sheet.setText(9, 1, '##,##0.00'); this.sheet.setText(9, 2, ''); this.sheet.setText(9, 3, ''); this.sheet.setText(9, 4, ' -'); this.sheet.setText(9, 5, ''); this.sheet.setText(9, 6, ''); this.sheet .getRange(6, 1, 1, 6).backColor('#FFF3CE') this.sheet .getRange(6, 1, 4, 6) .setBorder(new GC2.Spread.Sheets.LineBorder('orange', GC2.Spread.Sheets.LineStyle.thin), { all: true }); this.sheet .getRange(6, 1, 4, 6) .setBorder(new GC2.Spread.Sheets.LineBorder('orange', GC2.Spread.Sheets.LineStyle.medium), { outline: true }); this.sheet.setText(12, 0, 'パネルで各プロパティを変更すると、B3セルのGcNumber型セルに設定されます。'); this.sheet.setText(13, 0, '書式で使用できるキーワードの詳細については、InputManJSのヘルプまたはオンラインデモをご参照ください。'); this.sheet.setValue(2, 1, 1000); this.refresh(); this.sheet.resumePaint(); } refresh() { var formatDigit, positivePrefix, positiveSuffix, negativePrefix, negativeSuffix; switch (this.formatPattern) { case 0: formatDigit = '#####'; positivePrefix = '$'; positiveSuffix = ''; negativePrefix = '-$'; negativeSuffix = ''; break; case 1: formatDigit = '##,##0'; positivePrefix = '税込 '; positiveSuffix = '円'; negativePrefix = '税込 ▲'; negativeSuffix = '円'; break; case 2: formatDigit = '##,##0.00'; positivePrefix = ''; positiveSuffix = ''; negativePrefix = '-'; negativeSuffix = ''; break; default: break; } var gcNumberCellType = new GcNumberCellType({ formatDigit: formatDigit, positivePrefix: positivePrefix, positiveSuffix: positiveSuffix, negativePrefix: negativePrefix, negativeSuffix: negativeSuffix, displayType: this.displayTypeValue ? 'text' : 'value', showSpinButton: this.showSpinButton, showNumericPad: this.showNumericPad, minValue: this.minValue, maxValue: this.maxValue, watermarkNullText: this.watermarkNullText ? '値を入力してください' : '' }); this.sheet.setCellType(2, 1, gcNumberCellType); this.sheet.setActiveCell(2, 1); }; public setMaxValue(value: any) { this.maxValue = value.target.value; this.refresh(); } public setMinValue(value: any) { this.minValue = value.target.value; this.refresh(); } } enableProdMode(); bootstrapApplication(AppComponent);
<!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$/ja/angular/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- Polyfills --> <script src="$DEMOROOT$/ja/angular/node_modules/core-js/client/shim.min.js"></script> <script src="$DEMOROOT$/ja/angular/node_modules/zone.js/fesm2015/zone.min.js"></script> <!-- SystemJS --> <script src="$DEMOROOT$/ja/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.import('@angular/compiler'); System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('$DEMOROOT$/ja/lib/angular/license.ts'); System.import('$DEMOROOT$/spread/source/js/inputman/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"> <label for="format">書式 </label> <select id="format" (change)="formatPattern=$event.target.selectedIndex;refresh()"> <option *ngFor="let c of formatPatterns">{{c}}</option> </select><br><br> <label><input id="displayTypeText" type="checkbox" [(ngModel)]="displayTypeValue" (change)="refresh()">入力書式と同じ文字列をセルに表示</label><br><br> <label><input id="showSpinButton" type="checkbox" [(ngModel)]="showSpinButton" (change)="refresh()">スピンボタン</label><br><br> <label><input id="showNumericPad" type="checkbox" [(ngModel)]="showNumericPad" (change)="refresh()">ドロップダウンキーパッド</label><br><br> <label>最小値 </label><gc-number [value]="-99999" (change)="setMinValue($event)"></gc-number><br><br> <label>最大値 </label><gc-number [value]="99999" (change)="setMaxValue($event)"></gc-number><br><br> <label><input id="watermarkNullText" type="checkbox" [(ngModel)]="watermarkNullText" (change)="refresh()">未入力時の代替テキスト</label><br><br> </div> </div>
/* ウォーターマークのスタイル */ .gcim_watermark_null { color: lightgrey; } .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 { padding-bottom: 8px; } 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/fesm2015/zone.min.js', 'rxjs': 'npm:rxjs/dist/bundles/rxjs.umd.min.js', '@angular/core': 'npm:@angular/core/fesm2022', '@angular/common': 'npm:@angular/common/fesm2022/common.mjs', '@angular/compiler': 'npm:@angular/compiler/fesm2022/compiler.mjs', '@angular/platform-browser': 'npm:@angular/platform-browser/fesm2022/platform-browser.mjs', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/fesm2022/platform-browser-dynamic.mjs', '@angular/common/http': 'npm:@angular/common/fesm2022/http.mjs', '@angular/router': 'npm:@angular/router/fesm2022/router.mjs', '@angular/forms': 'npm:@angular/forms/fesm2022/forms.mjs', 'jszip': 'npm:jszip/dist/jszip.min.js', 'typescript': 'npm:typescript/lib/typescript.js', 'ts': './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', 'tslib':'npm:tslib/tslib.js', '@grapecity/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ja': 'npm:@mescius/spread-sheets-resources-ja/index.js', '@mescius/spread-sheets-angular': 'npm:@mescius/spread-sheets-angular/fesm2020/mescius-spread-sheets-angular.mjs', '@mescius/spread-sheets-inputmancelltype': 'npm:@mescius/spread-sheets-inputmancelltype/index.js', '@mescius/inputman': 'npm:@mescius/inputman/index.js', "@mescius/inputman/CSS": "npm:@mescius/inputman/CSS", "@mescius/inputman.angular": "npm:@mescius/inputman.angular/fesm2020/grapecity-inputman.angular.mjs", '@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', meta: { "*.component.ts": { loader: "system.component-loader.js" } } }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, "node_modules/@angular": { defaultExtension: 'mjs' }, "@mescius/spread-sheets-angular": { defaultExtension: 'mjs' }, '@angular/core': { defaultExtension: 'mjs', main: 'core.mjs' }, "@mescius/inputman.angular": { defaultExtension: 'mjs' }, } }); })(this);