사용자는 데이터를 추가하거나 복사하여 붙여넣기, 끌어서 채우기 및 끌어서 놓기 작업을 사용하여 표 범위를 자동으로 확장할 수 있습니다. 작업에 따라 새 표 열이 표 오른쪽에 삽입되거나 새 표 행이 마지막 행 아래에 추가됩니다.
1. 표 열 바로 오른쪽 또는 마지막 표 행 바로 뒤에 데이터를 추가합니다.
2. 현재 표 범위를 초과하는 데이터를 붙여넣습니다.
3. 표 범위에서 끌어서 채웁니다.
4. 범위를 표 범위로 끌어서 놓습니다.
allowAutoExpand을 사용하여 자동 확장 기능을 활성화/비활성화할 수 있습니다.
이 API를 통해 자동 확장 토글 상태를 가져올 수도 있습니다.
<template>
<div class="sample-tutorial">
<gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread">
</gc-spread-sheets>
<div class="options-container">
<p>Select the table in the Spread instance and change the state of allow table auto expand.</p>
<div class="option-group">
<input type="checkbox" id="allowAutoExpand" v-bind:checked="isAllowAutoExpand" v-on:change="onAllowAutoExpand" />
<label for="allowAutoExpand">Allow Table Auto Expand</label>
</div>
</div>
</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';
const GCsheets = GC.Spread.Sheets;
let App = Vue.extend({
name: "app",
data: function() {
return {
spread: null,
table: null,
isAllowAutoExpand: true
};
},
methods:{
initSpread: function (spread) {
this.spread = spread;
spread.suspendPaint();
let sheet = spread.getActiveSheet();
this.table = sheet.tables.add("table1", 1, 1, 4, 4, GCsheets.Tables.TableThemes.light1);
sheet.setColumnWidth(1, 120);
sheet.setColumnWidth(2, 120);
sheet.setColumnWidth(3, 120);
sheet.setColumnWidth(4, 120);
sheet.getCell(1, 1).text("First Name");
sheet.getCell(1, 2).text("Last Name");
sheet.getCell(1, 3).text("Score");
sheet.getCell(1, 4).text("Position");
sheet.getCell(2, 1).text("Alexa");
sheet.getCell(2, 2).text("Wilder");
sheet.getCell(2, 3).text("90");
sheet.getCell(2, 4).text("Web Developer");
sheet.getCell(3, 1).text("Victor");
sheet.getCell(3, 2).text("Wooten");
sheet.getCell(3, 3).text("70");
sheet.getCell(3, 4).text(".NET Developer");
sheet.getCell(4, 1).text("Ifeoma");
sheet.getCell(4, 2).text("Mays");
sheet.getCell(4, 3).text("85");
sheet.getCell(4, 4).text("Sales Manager");
spread.resumePaint();
},
onAllowAutoExpand(e) {
let table = this.table;
if (table) {
try {
let checked = !this.isAllowAutoExpand;
this.isAllowAutoExpand = checked;
table.allowAutoExpand(checked);
} catch (ex) {
alert(!!ex.message ? ex.message : ex);
}
}
}
}
});
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 {
position: relative;
height: 100%;
overflow: auto;
}
.sample::after {
display: block;
content: "";
clear: both;
}
.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;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.option-row {
font-size: 14px;
padding: 5px;
margin-top: 10px;
}
.option-group {
margin-bottom: 6px;
}
label {
display: inline-block;
min-width: 90px;
margin-bottom: 6px;
}
select {
padding: 4px 6px;
}
p {
padding: 0 0 12px;
margin: 0;
}
.options-toggle {
display: none;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
(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);