시트에 수동으로 데이터를 입력하는 대신 자동 채우기 기능을 사용하여 패턴을 따르거나 다른 셀의 데이터를 기반으로 하는 데이터로 셀을 채울 수 있습니다. 이 기능은 사용자를 위한 템플릿을 디자인할 때, 데이터에 반복 또는 패턴이 있는 경우 유용할 수 있습니다.
여러 유형의 데이터 계열을 빠르게 채우려면 셀을 선택하고 채우기 핸들을 끌 수 있습니다. 채우기 핸들을 사용하려면 추가 셀 채우기의 기초로 사용할 셀을 선택한 다음 채우기 핸들을 채우려는 셀 위나 아래로 끕니다.
Ctrl 키를 누른 상태에서 두 개 이상의 셀 중에서 선택하여 채우기 핸들을 끌어서 계열 자동 채우기를 억제할 수 있습니다. 끌어서 채운 후 자동 채우기 옵션 단추가 표시됩니다. 해당 단추를 클릭하고 선택 영역이 채워지는 방식을 변경할 수 있습니다. 예를 들어, 서식만 채우기를 클릭하여 셀 서식만 채울 수 있습니다. 제공되는 자동 채우기 옵션은 다음과 같습니다:
CopyCells: 값, 서식 및 수식을 포함하여 모든 데이터 개체로 셀을 채웁니다.
FillSeries: 계열로 셀을 채웁니다.
FillFormattingOnly: 서식으로만 셀을 채웁니다.
FillWithoutFormatting: 서식을 제외한 값으로 셀을 채웁니다.
시작 범위로 끌어서 채우기를 사용하여 채워진 값을 지울 수도 있습니다.
채우기 핸들을 끌 때 기본적으로 SpreadJS는 채울 영역의 새로운 끌어온 가장자리를 보여주는 설명을 표시합니다. 다음 예와 같이 설명 표시를 끌 수 있습니다:
사용자 정의 목록 채우기 SpreadJS는 사용자 정의 목록을 지원하기 위해 끌어서 채우기 동작을 개선합니다. 사용자 정의 목록과 일치하는 값을 채웁니다.
SpreadJS는 기본 제공 사용자 정의 목록에서 요일 및 월을 제공합니다. 또한 다음 예제에서 사용자 정의 목록을 설정할 수 있습니다.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import './styles.css';
import { AppFunc } from './app-func';
import { App } from './app-class';
// 1. Functional Component sample
ReactDOM.render(<AppFunc />, document.getElementById('app'));
// 2. Class Component sample
// ReactDOM.render(<App />, document.getElementById('app'));
import React, { useState, useEffect } from 'react';
import * as ReactDOM from 'react-dom';
import GC from '@mescius/spread-sheets';
import { SpreadSheets, Worksheet, Column } from '@mescius/spread-sheets-react';
import '@mescius/spread-sheets-resources-ko';
GC.Spread.Common.CultureManager.culture("ko-kr");
import './styles.css';
const Component = React.Component;
export function AppFunc() {
const [spread,setSpread] = useState(null);
const [showDragFillTip, setShowDragFillTip] = useState(true);
const [showDragFillSmartTag, setShowDragFillSmartTag] = useState(true);
const [defaultDragFillType, setDefaultDragFillType] = useState(5);
let initSheet0 = function (spread) {
let sheet = spread.getSheet(0);
sheet.name("Base Fill");
sheet.setValue(1, 1, "Select a cell with data below, hold your cursor over the bottom right border until you see the ‘+’,");
sheet.setValue(2, 1, "Then drag down to autofill the cell data. You can also hold the <Ctrl> key down to auto-increment the values and you can double-click to fill it automatically:");
let simpleData = [
[1.0, 1],
[1.1, 2]
];
let dateData = [
[new Date(2018, 3, 1), new Date(2017, 11, 1), new Date(2018, 2, 31), new Date(2017, 11, 31)],
[new Date(2018, 4, 1), new Date(2018, 0, 1), new Date(2018, 3, 30), new Date(2018, 0, 31)]
];
sheet.setArray(4, 1, simpleData);
sheet.setArray(4, 4, dateData);
for (let i = 6; i < 15; i++) {
sheet.setValue(i, 0, "Fill Data");
}
for (let i = 4; i < 8; i++) {
sheet.setColumnWidth(i, 80);
}
let dateCell = sheet.getRange(4, 4, 2, 4).formatter('m/d/yyyy');
};
let initsheet1 = function (spread) {
let sheet = spread.getSheet(1);
sheet.name("String Fill");
sheet.setValue(0, 0, 'N: number, S: string. DragFill for string, detecting number from end to start, SN first and NS second. Trend N if S is same.');
let title = sheet.getCell(0, 0);
title.font("15px 'Franklin Gothic Medium'");
sheet.setValue(1, 0, 'String contains numbers only. Please drag up or down.');
sheet.setValue(6, 0, '123');
sheet.setValue(7, 0, '125');
sheet.setValue(6, 2, '-3');
sheet.setValue(7, 2, '-2');
sheet.setValue(6, 4, '003');
sheet.setValue(7, 4, '007');
sheet.setValue(1, 8, 'String contains number in the end of string. Please drag up or down and choose "Fill Series" for the single one.');
sheet.setValue(6, 8, 'a2');
sheet.setValue(6, 10, 'a1');
sheet.setValue(7, 10, 'a5');
sheet.setValue(6, 12, 'a001');
sheet.setValue(7, 12, 'a002');
sheet.setValue(6, 14, '1a2a3a4a5');
sheet.setValue(7, 14, '1a2a3a4a6');
sheet.setColumnWidth(14, 100);
sheet.setValue(24, 0, 'String contains number in the first of string. Please drag up or down.');
sheet.setValue(30, 0, '5a');
sheet.setValue(31, 0, '2a');
sheet.setValue(30, 2, '003b');
sheet.setValue(31, 2, '005b');
sheet.setValue(30, 4, '1a1a1a');
sheet.setValue(31, 4, '2a1a1a');
sheet.setValue(24, 8, 'String just to copy. Please drag up or down.');
sheet.setValue(30, 8, 'a1a1');
sheet.setValue(31, 8, 'a2a2');
sheet.setValue(30, 10, '1a1');
sheet.setValue(31, 10, '2a2');
sheet.setValue(30, 12, 'a1');
sheet.setValue(31, 12, 'b2');
}
let initsheet2 = function (spread) {
let sheet = spread.getSheet(2);
sheet.name("Custom Fill");
sheet.setValue(0, 0, 'Custom list for dragfill. Please drag up or down.');
sheet.setValue(6, 0, 'Mar');
sheet.setValue(7, 0, 'Apr');
sheet.setValue(6, 2, 'June');
sheet.setValue(7, 2, 'July');
sheet.setValue(6, 4, 'Mon');
sheet.setValue(7, 4, 'Tue');
sheet.setValue(6, 6, 'Friday');
sheet.setValue(7, 6, 'Saturday');
sheet.setValue(20, 0, 'The custom list customized two array currently, and shows as following. Enter one or more consecutive ones in the list to dragfill.');
let customList = sheet.parent.options.customList;
for (let i = 0; i < customList.length; i++) {
let itemList = customList[i];
sheet.setValue(21 + i, 0, 'List ' + i + ": ");
itemList.forEach(function (item, index) {
sheet.setValue(21 + i, index + 1, item);
});
}
}
let updateShowDragFillTip = function (value) {
setShowDragFillTip(value);
spread.options.showDragFillTip = value;
}
let updateShowDragFillSmartTag = function (value) {
setShowDragFillSmartTag(value);
spread.options.showDragFillSmartTag = value;
}
let updateDefaultDragFillType = function (type) {
type = parseInt(type, 10);
setDefaultDragFillType(type);
if (!isNaN(type)) {
spread.options.defaultDragFillType = type;
}
}
let initSpread = function (value) {
setSpread(value);
let customList = [
['Light', 'Sun', 'Moon', 'Star', 'Sky', 'Rain', 'Cloud'],
['Dog', 'Cat', 'Lion', 'Fish', 'Snake']
];
value.options.customList = customList;
value.suspendPaint();
initSheet0(value);
initsheet1(value);
initsheet2(value);
value.resumePaint();
}
return (
<div class="sample-tutorial">
<div class="sample-spreadsheets">
<SpreadSheets workbookInitialized={spread => initSpread(spread)}>
<Worksheet></Worksheet>
<Worksheet></Worksheet>
<Worksheet></Worksheet>
</SpreadSheets>
</div>
<Panel
showDragFillSmartTag = {showDragFillSmartTag}
showDragFillTip = {showDragFillTip}
defaultDragFillType = {defaultDragFillType}
updateShowDragFillTip={(value) => { updateShowDragFillTip(value) }}
updateShowDragFillSmartTag={(value) => { updateShowDragFillSmartTag(value) }}
updateDefaultDragFillType={(type) => { updateDefaultDragFillType(type) }}
></Panel>
</div>
)
}
const Panel = React.memo((props)=>{
return (<div class="options-container">
<div class="option-row">
<p>
Try checking the options on the right side and following the instructions in the sheet to see how those options affect the fill operations.
</p>
<label for="dragFillType">Default Drag Fill Type:</label>
<select id="dragFillType" title="Select one for default drag fill type." value={props.defaultDragFillType} onChange={(event) => { props.updateDefaultDragFillType(event.target.value) }}>
<option value={5} >Auto</option>
<option value={0} >Copy Cells</option>
<option value={1} >Fill Series</option>
<option value={2} >Fill Formatting Only</option>
<option value={3} >Fill Without Formatting</option>
</select>
</div>
<div class="option-row">
<input type="checkbox" id="chkShowDragFillTip" checked={props.showDragFillTip} onChange={(event) => { props.updateShowDragFillTip(event.target.checked) }} />
<label for="chkShowDragFillTip">Show Drag Fill Tip</label>
</div>
<div class="option-row">
<input id="chkShowDragFillSmartTag" type="checkbox" checked={props.showDragFillSmartTag} onChange={(event) => { props.updateShowDragFillSmartTag(event.target.checked) }} />
<label for="chkShowDragFillSmartTag">Show Drag Fill Smart Tag</label>
</div>
</div>)
});
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import GC from '@mescius/spread-sheets';
import { SpreadSheets, Worksheet, Column } from '@mescius/spread-sheets-react';
import '@mescius/spread-sheets-resources-ko';
GC.Spread.Common.CultureManager.culture("ko-kr");
import './styles.css';
const Component = React.Component;
const initSheet0 = (spread) => {
let sheet = spread.getSheet(0);
sheet.name("Base Fill");
sheet.setValue(1, 1, "Select a cell with data below, hold your cursor over the bottom right border until you see the ‘+’,");
sheet.setValue(2, 1, "Then drag down to autofill the cell data. You can also hold the <Ctrl> key down to auto-increment the values and you can double-click to fill it automatically:");
let simpleData = [
[1.0, 1],
[1.1, 2]
];
let dateData = [
[new Date(2018, 3, 1), new Date(2017, 11, 1), new Date(2018, 2, 31), new Date(2017, 11, 31)],
[new Date(2018, 4, 1), new Date(2018, 0, 1), new Date(2018, 3, 30), new Date(2018, 0, 31)]
];
sheet.setArray(4, 1, simpleData);
sheet.setArray(4, 4, dateData);
for (let i = 6; i < 15; i++) {
sheet.setValue(i, 0, "Fill Data");
}
for (let i = 4; i < 8; i++) {
sheet.setColumnWidth(i, 80);
}
let dateCell = sheet.getRange(4, 4, 2, 4).formatter('m/d/yyyy');
};
const initsheet1 = (spread) => {
let sheet = spread.getSheet(1);
sheet.name("String Fill");
sheet.setValue(0, 0, 'N: number, S: string. DragFill for string, detecting number from end to start, SN first and NS second. Trend N if S is same.');
let title = sheet.getCell(0, 0);
title.font("15px 'Franklin Gothic Medium'");
sheet.setValue(1, 0, 'String contains numbers only. Please drag up or down.');
sheet.setValue(6, 0, '123');
sheet.setValue(7, 0, '125');
sheet.setValue(6, 2, '-3');
sheet.setValue(7, 2, '-2');
sheet.setValue(6, 4, '003');
sheet.setValue(7, 4, '007');
sheet.setValue(1, 8, 'String contains number in the end of string. Please drag up or down and choose "Fill Series" for the single one.');
sheet.setValue(6, 8, 'a2');
sheet.setValue(6, 10, 'a1');
sheet.setValue(7, 10, 'a5');
sheet.setValue(6, 12, 'a001');
sheet.setValue(7, 12, 'a002');
sheet.setValue(6, 14, '1a2a3a4a5');
sheet.setValue(7, 14, '1a2a3a4a6');
sheet.setColumnWidth(14, 100);
sheet.setValue(24, 0, 'String contains number in the first of string. Please drag up or down.');
sheet.setValue(30, 0, '5a');
sheet.setValue(31, 0, '2a');
sheet.setValue(30, 2, '003b');
sheet.setValue(31, 2, '005b');
sheet.setValue(30, 4, '1a1a1a');
sheet.setValue(31, 4, '2a1a1a');
sheet.setValue(24, 8, 'String just to copy. Please drag up or down.');
sheet.setValue(30, 8, 'a1a1');
sheet.setValue(31, 8, 'a2a2');
sheet.setValue(30, 10, '1a1');
sheet.setValue(31, 10, '2a2');
sheet.setValue(30, 12, 'a1');
sheet.setValue(31, 12, 'b2');
}
const initsheet2 = (spread) => {
let sheet = spread.getSheet(2);
sheet.name("Custom Fill");
sheet.setValue(0, 0, 'Custom list for dragfill. Please drag up or down.');
sheet.setValue(6, 0, 'Mar');
sheet.setValue(7, 0, 'Apr');
sheet.setValue(6, 2, 'June');
sheet.setValue(7, 2, 'July');
sheet.setValue(6, 4, 'Mon');
sheet.setValue(7, 4, 'Tue');
sheet.setValue(6, 6, 'Friday');
sheet.setValue(7, 6, 'Saturday');
sheet.setValue(20, 0, 'The custom list customized two array currently, and shows as following. Enter one or more consecutive ones in the list to dragfill.');
let customList = sheet.parent.options.customList;
for (let i = 0; i < customList.length; i++) {
let itemList = customList[i];
sheet.setValue(21 + i, 0, 'List ' + i + ": ");
itemList.forEach(function (item, index) {
sheet.setValue(21 + i, index + 1, item);
});
}
}
export class App extends Component {
constructor(props) {
super(props);
this.spread = null;
this.state = {
showDragFillTip: true,
showDragFillSmartTag: true,
defaultDragFillType: 5
};
}
render() {
return (
<div class="sample-tutorial">
<div class="sample-spreadsheets">
<SpreadSheets workbookInitialized={spread => this.initSpread(spread)}>
<Worksheet></Worksheet>
<Worksheet></Worksheet>
<Worksheet></Worksheet>
</SpreadSheets>
</div>
<Panel
showDragFillTip={this.state.showDragFillTip}
showDragFillSmartTag={this.state.showDragFillSmartTag}
defaultDragFillType={this.state.defaultDragFillType}
updateShowDragFillTip={(value) => { this.updateShowDragFillTip(value) }}
updateShowDragFillSmartTag={(value) => { this.updateShowDragFillSmartTag(value) }}
updateDefaultDragFillType={(type) => { this.updateDefaultDragFillType(type) }}
></Panel>
</div>
)
}
updateShowDragFillTip(value) {
this.setState({showDragFillTip:value});
this.spread.options.showDragFillTip = value;
}
updateShowDragFillSmartTag(value) {
this.setState({showDragFillSmartTag:value});
this.spread.options.showDragFillSmartTag = value;
}
updateDefaultDragFillType(type) {
type = parseInt(type, 10);
this.setState({defaultDragFillType:type});
if (!isNaN(type)) {
this.spread.options.defaultDragFillType = type;
}
}
initSpread(spread) {
this.spread = spread;
let customList = [
['Light', 'Sun', 'Moon', 'Star', 'Sky', 'Rain', 'Cloud'],
['Dog', 'Cat', 'Lion', 'Fish', 'Snake']
];
spread.options.customList = customList;
spread.suspendPaint();
initSheet0(spread);
initsheet1(spread);
initsheet2(spread);
spread.resumePaint();
}
}
const Panel = (props) => {
const {
showDragFillTip,
showDragFillSmartTag,
defaultDragFillType,
updateShowDragFillTip,
updateShowDragFillSmartTag,
updateDefaultDragFillType
} = props;
return (
<div class="options-container">
<div class="option-row">
<p>
Try checking the options on the right side and following the instructions in the sheet to see how those options affect the fill operations.
</p>
<label for="dragFillType">Default Drag Fill Type:</label>
<select id="dragFillType" title="Select one for default drag fill type." value = {defaultDragFillType} onChange={(event) => { updateDefaultDragFillType(event.target.value)}}>
<option value={5} >Auto</option>
<option value={0} >Copy Cells</option>
<option value={1} >Fill Series</option>
<option value={2} >Fill Formatting Only</option>
<option value={3} >Fill Without Formatting</option>
</select>
</div>
<div class="option-row">
<input type="checkbox" id="chkShowDragFillTip" checked= {showDragFillTip} onChange={(event) => { updateShowDragFillTip(event.checked)}}/>
<label for="chkShowDragFillTip">Show Drag Fill Tip</label>
</div>
<div class="option-row">
<input id="chkShowDragFillSmartTag" type="checkbox" checked={showDragFillSmartTag} onChange={(event) => { updateShowDragFillSmartTag(event.checked)}} />
<label for="chkShowDragFillSmartTag">Show Drag Fill Smart Tag</label>
</div>
</div>
)
}
<!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/react/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<!-- SystemJS -->
<script src="$DEMOROOT$/ko/react/node_modules/systemjs/dist/system.src.js"></script>
<script src="$DEMOROOT$/spread/source/data/ellipsis.js" type="text/javascript"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('$DEMOROOT$/ko/lib/react/license.js').then(function () {
System.import('./src/app');
});
</script>
</head>
<body>
<div id="app" style="height: 100%;"></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;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.option-row {
font-size: 14px;
padding: 5px;
margin-top: 10px;
}
select {
padding: 4px 8px;
width: 100%;
box-sizing: border-box;
margin-top: 4px;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
(function (global) {
System.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true,
react: true
},
meta: {
'*.css': { loader: 'css' }
},
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-react': 'npm:@mescius/spread-sheets-react/index.js',
'@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js',
'react': 'npm:react/umd/react.production.min.js',
'react-dom': 'npm:react-dom/umd/react-dom.production.min.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'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
src: {
defaultExtension: 'jsx'
},
"node_modules": {
defaultExtension: 'js'
},
}
});
})(this);