붙여넣기, 잘라내기, 복사 및 자동 채우기와 같은 기본 제공 도구 상자 항목을 사용할 수 있습니다.
또한 터치 도구 상자 항목을 사용자 정의하여 터치 도구 상자에 추가할 수 있습니다.
text 메서드를 사용하여 항목의 텍스트를 가져오거나 설정하고, font 메서드를 사용하여 항목 텍스트의 글꼴을 가져오거나 설정하고, foreColor 메서드를 사용하여 항목 텍스트의 색을 가져오거나 설정할 수 있습니다.
터치 도구 상자 항목을 추가한 후에는 getItem 및 getItems를 사용할 수 있습니다. 또한 한 항목을 제거하거나 모든 항목을 지울 수 있습니다.
제공된 API를 사용하여 도구 상자를 사용자 정의할 수 있습니다. 예:
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 3});
initSpread(spread);
};
function _getElementById(id) {
return document.getElementById(id);
}
function initSpread(spread) {
var sheet = spread.sheets[0];
_getElementById('addItem').onclick = function () {
var name = _getElementById('name').value;
if (!name) {
alert("Please input a name for toolbar item.")
}
var text = _getElementById('text').value;
var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8' +
'YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABMklEQVRIS7XSMUpDQRDG8YCt' +
'FxDsbb1H4lW8wnt38BA2VmIfC0mhhYVVIJXybC0U0gibbx47w+zm290nPIsfbDY7/4GQRQjhX9HLOdHL' +
'OdHLOdFL5ut243UQMnI3fu/nkg81OhxDeVyNS/xc8qFGBmOAhb3OzyWRGhnMQkV+LonU/Dxt1yzG+Dk7' +
'bJ5fSrrtbrfGm7B/e6fBnDZFa0EHQXwMA55NWyI9VVtgcTVxSa9NUVpwFFeNJT1YU7AFxbgqLBnjrQXN' +
'uNIl+Hc9+nhtwVkeaYn/riSYswMGVnmg4ReufYyxAx5P/nngG64giTF2wOP7ONwywCXITBJj7IDHn8CC' +
'3iucwxgXPsbYAY97YFH1AKdgceFjjB3iQGnJDZxAEhc+xtDL3MXyLvyVzh7F5hUWB34T0LLVazuTAAAA' +
'AElFTkSuQmCC';
var item = new GC.Spread.Sheets.Touch.TouchToolStripItem(name, text, image, function () {
spread.touchToolStrip.close();
alert("Runing clearing...");
});
spread.touchToolStrip.add(item);
};
_getElementById('removeItem').onclick = function () {
var name = _getElementById('name').value;
if (!name) {
alert("Please input the name which item to be removed.");
}
spread.touchToolStrip.remove(name);
};
_getElementById('clear').onclick = function () {
spread.touchToolStrip.clear();
}
_getElementById('addSeparator').onclick = function () {
spread.touchToolStrip.add(new GC.Spread.Sheets.Touch.TouchToolStripSeparator());
};
_getElementById('setFont').onclick = function () {
var font = _getElementById('font').value;
if (!font) {
alert("Please input a font for item text.");
}
var name = _getElementById('name').value;
var item = spread.touchToolStrip.getItem(name);
if (item) {
item.font(font);
}
};
_getElementById('setForeColor').onclick = function () {
var foreColor = _getElementById('color').value;
if (!foreColor) {
alert("Please input a color for item text.");
}
var name = _getElementById('name').value;
var item = spread.touchToolStrip.getItem(name);
if (item) {
item.foreColor(foreColor);
}
};
};
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="ko-kr"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets-resources-ko/dist/gc.spread.sheets.resources.ko.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-spreadsheets"></div>
<div class="options-container">
<div class="option-row">
<span>Select a cell using a touch enabled device.Select that cell again to view the customizable touch toolstrip.
</span>
</div>
<div class="option-row">
<span>Customize Toolstrip</span>
</div>
<div class="option-row">
<span>Add new menu item:</span>
</div>
<div class="option-row">
<label for="name">Name:</label>
<input id="name" value="demo_clear"/>
</div>
<div class="option-row">
<label for="text">Text:</label>
<input id="text" value="clear"/>
</div>
<div class="option-row">
<input type="button" value="Add Item" id="addItem" class="toolbar-setting"/>
<input type="button" value="Add Separator" id="addSeparator" class="toolbar-setting"/>
</div>
<span>Toolstrip Item Style:</span>
<div class="option-row">
<input id="font" value="18px Arial"/>
<input type="button" id="setFont" value="Set Font"
title="Set font for toolstrip item with specified name"/>
</div>
<div class="option-row">
<input id="color" value="red"/>
<input type="button" id="setForeColor" value="Set Fore Color"
title="Set fore color for toolstrip item with specified name"/>
</div>
<div class="option-row">
<input type="button" value="Remove Toolstrip Item" id="removeItem"/>
<input type="button" value="Clear All Toolstrip Items" id="clear"/>
</div>
</div>
</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;
}
label {
display: inline-block;
min-width: 80px;
}
input,
select {
padding: 4px 8px;
margin-top: 6px;
width: 100%;
box-sizing: border-box;
}
.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;
}