getSheetPosition 메서드를 사용하여 시트 위치를 얻을 수 있습니다. 예:
changeSheetPosition 메서드를 사용하여 시트 위치를 변경할 수도 있습니다. 예:
또한, 하위 속성 sheetPosition은 이벤트 GC.Spread.Sheets.Events.SheetChanging 및 이벤트 GC.Spread.Sheets.Events.SheetChanged에 추가됩니다.
/*REPLACE_MARKER*/
/*DO NOT DELETE THESE COMMENTS*/
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(_getElementById('ss'), { sheetCount: 3 });
initSpread(spread);
bindEvent(spread);
};
function initSpread(spread) {
spread.suspendPaint();
spread.options.autoFitType = GC.Spread.Sheets.AutoFitType.cellWithHeader;
//init a data manager
var tableName = "Supplier";
var baseApiUrl = getBaseApiUrl();
var apiUrl = baseApiUrl + "/" + tableName;
var dataManager = spread.dataManager();
var myTable = dataManager.addTable("myTable", {
remote: {
read: {
url: apiUrl
}
}
});
//init a table sheet
var sheet = spread.addSheetTab(0, "TableSheet1", GC.Spread.Sheets.SheetType.tableSheet);
sheet.options.allowAddNew = false; //hide new row
//bind a view to the table sheet
myTable.fetch().then(function () {
var view = myTable.addView("myView", [
{ value: "Id", width: 80 },
{ value: "CompanyName", width: 200, caption: "Company Name" },
{ value: "ContactName", width: 150, caption: "Contact" },
{ value: "ContactTitle", width: 200, caption: "Title" },
{ value: "Address", width: 200 },
{ value: "City", width: 150, caption: "City" },
{ value: "State", width: 100, caption: "State" },
{ value: "Region", width: 100, caption: "Region" }
]);
sheet.setDataView(view);
});
spread.resumePaint();
}
function bindEvent(spread) {
let button = _getElementById("getSheetPosition");
button.addEventListener("click", function () {
let input = _getElementById("sheetPosition");
let sheetName, sheet = spread.getActiveSheet();
if (sheet) {
sheetName = sheet.name();
} else {
sheet = spread.getActiveSheetTab();
if (sheet) {
sheetName = sheet.name();
}
}
if (sheetName) {
input.value = sheetName + "'s position is " + spread.getSheetPosition(sheetName);
} else {
input.value = "";
}
})
}
function getBaseApiUrl() {
return window.location.href.match(/http.+spreadjs\/learn-spreadjs\//)[0] + 'server/api';
}
function _getElementById(id) {
return document.getElementById(id);
}
<!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">
<!-- Promise Polyfill for IE, https://www.npmjs.com/package/promise-polyfill -->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
<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-tablesheet/dist/gc.spread.sheets.tablesheet.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">
<input type="button" id="getSheetPosition" value="Get Sheet Position" />
</div>
<div class="option-row">
<input id="sheetPosition" />
</div>
</div>
</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;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}