작업

SpreadJS의 태그는 서로 다른 작업이 수행될 때 영향을 받습니다. 태그가 있는 셀을 복사하여 붙여넣거나 끌어서 놓으면 어떻게 되는지 확인하십시오.

다음 작업은 태그에 다음과 같이 영향을 미칩니다: 잘라내기/붙여넣기 또는 끌어서 놓기 동작이 발생하면 태그 데이터가 셀과 함께 이동합니다. 복사/붙여넣기 또는 끌기/채우기 동작이 발생하면 태그 데이터가 복사됩니다. 태그 유형이 복합 형식이면 복제됩니다. 태그 작업이 완료되면 실행 취소하거나 다시 실행할 수 있습니다.
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 1}); initSpread(spread); }; function initSpread(spread) { var spreadNS = GC.Spread.Sheets, sheet = spread.sheets[0]; sheet.suspendPaint(); // set drag fill type to CopyCells in order to demo tag will be copied spread.options.defaultDragFillType = spreadNS.Fill.AutoFillType.copyCells; sheet.setArray(3, 1, [["a", 1], ["b", 2], ["c", 3]]); sheet.setTag(3, 1, "Tag for 'a'"); sheet.getCell(3, 1).backColor("#E3E3E3"); sheet.setTag(4, 2, "Number tag"); sheet.getCell(4, 2).backColor("#E3E3E3"); sheet.setTag(4, 1, {row: 12, column: 2}); sheet.getCell(4, 1).backColor("#E3E3E3"); sheet.setTag(5, 2, new Date(Date.UTC(2014, 7, 12))); sheet.getCell(5, 2).backColor("#E3E3E3"); sheet.bind(spreadNS.Events.EnterCell, function () { var tag = sheet.getTag(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); if (tag == null) { document.getElementById('txtTag').value = ""; } else if (typeof tag === "string") { document.getElementById('txtTag').value = tag; } else { document.getElementById('txtTag').value = JSON.stringify(tag); } }); sheet.resumePaint(); }
<!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"> <label for="txtTag">Selected Cell Tag: </label> <input type="text" id="txtTag" style="width: 200px" /> </div> <p style="background-color:#F4F8EB;padding: 4px;"> Select a cell, highlighted above, to get its cell tag using a custom string format. You can also copy and paste a cell with tag.<br /> Note: the defaultDragFillType is set to copyCells in this demo. </p> </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; } .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; } label { display: inline-block; margin-right: 6px; } input { padding: 4px; margin: 0 4px 4px 0; } p { background-color: #F4F8EB; padding: 4px; } p span { display: block; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }