スプレッドシート:固定セル

FlexSheetでは、freezeAtCursorメソッドを使用して、選択されたセルの行や列を固定することができます。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjFlexSheet from '@grapecity/wijmo.grid.sheet'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let frozenSheet = new wjFlexSheet.FlexSheet('#frozenSheet'); frozenSheet.addUnboundSheet('非連結', 30, 12); frozenSheet.deferUpdate(() => { let colIdx, rowIdx; for (colIdx = 0; colIdx < frozenSheet.columns.length; colIdx++) { for (rowIdx = 0; rowIdx < frozenSheet.rows.length; rowIdx++) { frozenSheet.setCellData(rowIdx, colIdx, colIdx + rowIdx); } } }); document.querySelector('#freezeButton').addEventListener('click', (e) => { frozenSheet.freezeAtCursor(); if (frozenSheet.frozenColumns > 0 || frozenSheet.frozenRows > 0) { e.target.textContent = 'セル固定の解除'; } else { e.target.textContent = 'セルの固定'; } }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexSheet Frozen Cells</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div id="frozenSheet"></div> <button id="freezeButton" type="button" class="btn btn-default">セルの固定</button> </div> </body> </html> .wj-flexsheet { height: 400px; margin: 6px 0; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import { Component, enableProdMode, NgModule, ViewChild } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGridSheetModule } from '@grapecity/wijmo.angular2.grid.sheet'; import * as wjcSheet from '@grapecity/wijmo.grid.sheet'; @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { isFrozen: boolean = false; @ViewChild('flex') flex: wjcSheet.FlexSheet; initializeFlexSheet(flex: wjcSheet.FlexSheet) { flex.deferUpdate(() => { let colIdx: number, rowIdx: number; for (colIdx = 0; colIdx < flex.columns.length; colIdx++) { for (rowIdx = 0; rowIdx < flex.rows.length; rowIdx++) { flex.setCellData(rowIdx, colIdx, colIdx + rowIdx); } } }); flex.selectedSheetChanged.addHandler(() => { if (flex.frozenColumns > 0 || flex.frozenRows > 0) { this.isFrozen = true; } else { this.isFrozen = false; } }); } freezeCells() { this.flex.freezeAtCursor(); if (this.flex.frozenColumns > 0 || this.flex.frozenRows > 0) { this.isFrozen = true; } else { this.isFrozen = false; } } } @NgModule({ imports: [WjGridSheetModule, BrowserModule], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexSheet Frozen Cells</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="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('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <!-- the flexsheet --> <wj-flex-sheet #flex (initialized)="initializeFlexSheet(flex)"> <wj-sheet [name]="'非連結'" [rowCount]="30" [columnCount]="12"></wj-sheet> </wj-flex-sheet> <button type="button" class="btn btn-default" (click)="freezeCells()">{{isFrozen ? 'セル固定の解除' : 'セルの固定'}}</button> </div> .wj-flexsheet { height: 400px; margin: 6px 0; } import './app.css'; import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjGridSheet from "@grapecity/wijmo.react.grid.sheet"; class App extends React.Component { constructor(props) { super(props); this.state = { isFrozen: false, flex: null }; } render() { return (<div className="container-fluid"> <wjGridSheet.FlexSheet initialized={this.initializeFlexSheet.bind(this)}> <wjGridSheet.Sheet name="非連結" rowCount={30} columnCount={12}></wjGridSheet.Sheet> </wjGridSheet.FlexSheet> <button type="button" className="btn btn-default" onClick={this.freezeCells.bind(this)}>{this.state.isFrozen ? 'セル固定の解除' : 'セルの固定'}</button> </div>); } initializeFlexSheet(flex) { flex.deferUpdate(() => { let colIdx, rowIdx; for (colIdx = 0; colIdx < flex.columns.length; colIdx++) { for (rowIdx = 0; rowIdx < flex.rows.length; rowIdx++) { flex.setCellData(rowIdx, colIdx, colIdx + rowIdx); } } }); flex.selectedSheetChanged.addHandler(() => { if (flex.frozenColumns > 0 || flex.frozenRows > 0) { this.setState({ isFrozen: true }); } else { this.setState({ isFrozen: false }); } }); this.setState({ flex: flex }); } freezeCells() { this.state.flex.freezeAtCursor(); if (this.state.flex.frozenColumns > 0 || this.state.flex.frozenRows > 0) { this.setState({ isFrozen: true }); } else { this.setState({ isFrozen: false }); } } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> .container-fluid .wj-flexsheet { height: 400px; margin: 6px 0; } <template> <div class="container-fluid"> <!-- the flexsheet --> <wj-flex-sheet :initialized="initializeFlexSheet"> <wj-sheet :name="'非連結'" :rowCount="30" :columnCount="12"></wj-sheet> </wj-flex-sheet> <button type="button" class="btn btn-default" @click="freezeCells" >{{isFrozen ? 'セル固定の解除' : 'セルの固定'}}</button> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import Vue from "vue"; import "@grapecity/wijmo.vue2.core"; import "@grapecity/wijmo.vue2.grid.sheet"; let App = Vue.extend({ name: "app", data: function() { return { isFrozen: false, flex: null }; }, methods: { initializeFlexSheet: function(flex) { flex.deferUpdate(() => { let colIdx, rowIdx; for (colIdx = 0; colIdx < flex.columns.length; colIdx++) { for (rowIdx = 0; rowIdx < flex.rows.length; rowIdx++) { flex.setCellData(rowIdx, colIdx, colIdx + rowIdx); } } }); flex.selectedSheetChanged.addHandler(() => { if (flex.frozenColumns > 0 || flex.frozenRows > 0) { this.isFrozen = true; } else { this.isFrozen = false; } }); this.flex = flex; }, freezeCells: function() { this.flex.freezeAtCursor(); if (this.flex.frozenColumns > 0 || this.flex.frozenRows > 0) { this.isFrozen = true; } else { this.isFrozen = false; } } } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <style> .container-fluid .wj-flexsheet { height: 400px; margin: 6px 0; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/jszip/dist/jszip.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html>