텍스트 맞춤

SpreadJS는 텍스트 맞춤을 지원하며, 개발자는 가로 맞춤세로 맞춤을 설정하여 원하는 텍스트 맞춤 효과를 얻을 수 있습니다.

다음과 같이 스타일을 만들고 맞춤을 설정할 수 있습니다. 그런 다음 이 스타일을 셀에 적용하여 텍스트 맞춤을 설정합니다. 아래 목록은 현재 SpreadJS가 지원하는 맞춤을 나타낸 것입니다. 가로 맞춤 : 왼쪽 가운데 오른쪽 선택 영역의 가운데로(CenterContinue) 분산 세로 맞춤: 위 가운데 아래
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 2 }); initSpread(spread); }; function initSpread(spread) { spread.fromJSON(jsonData); var sheet = spread.getActiveSheet(); sheet.suspendPaint(); // set table style sheet.getRange("C5:E5").backColor("Accent 1 80"); sheet.getRange("C6:C13").backColor("Accent 6 80"); sheet.addSpan(5, 2, 5, 1); sheet.addSpan(10, 2, 3, 1); sheet.setColumnWidth(2, 140); sheet.setColumnWidth(3, 200); sheet.setColumnWidth(4, 80); sheet.setRowHeight(10, 60); sheet.setRowHeight(11, 60); sheet.setRowHeight(12, 60); sheet.getRange("C6:C13").vAlign(GC.Spread.Sheets.VerticalAlign.center); sheet.getRange("C6:C13").hAlign(GC.Spread.Sheets.HorizontalAlign.center); sheet.getRange("C5:E5").hAlign(GC.Spread.Sheets.HorizontalAlign.centerContinuous); var lineStyle = GC.Spread.Sheets.LineStyle.dotted; var lineBorder = new GC.Spread.Sheets.LineBorder('black', lineStyle); sheet.getRange("C5:E13").setBorder(lineBorder, { all: true }); // set text sheet.setValue(4, 2, "Text Alignment"); sheet.setValue(5, 2, "Horizontal Alignment"); sheet.setValue(10, 2, "Vertical Alignment"); var hAlignData = [["Left"], ["Center"], ["Right"], ["Center Across Selection"],["Distributed Alignment"]]; var vAlignData = [["Top"], ["Center"], ["Bottom"]]; sheet.setArray(5, 3, hAlignData); sheet.setArray(10, 3, vAlignData); // set Alignment sheet.getStyle(5, 3).hAlign = GC.Spread.Sheets.HorizontalAlign.left; sheet.getStyle(6, 3).hAlign = GC.Spread.Sheets.HorizontalAlign.center; sheet.getStyle(7, 3).hAlign = GC.Spread.Sheets.HorizontalAlign.right; sheet.getRange(8, 3, 1, 2).hAlign(GC.Spread.Sheets.HorizontalAlign.centerContinuous); sheet.getStyle(9, 3).hAlign = GC.Spread.Sheets.HorizontalAlign.distributed; sheet.getStyle(10, 3).vAlign = GC.Spread.Sheets.VerticalAlign.top; sheet.getStyle(11, 3).vAlign = GC.Spread.Sheets.VerticalAlign.center; sheet.getStyle(12, 3).vAlign = GC.Spread.Sheets.VerticalAlign.bottom; sheet.resumePaint(); document.getElementById('HAlign0').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 0; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('HAlign1').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 1; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('HAlign2').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 2; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('HAlign3').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 4; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('HAlign4').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 5; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('VAlign0').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.vAlign = 0; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('VAlign1').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.vAlign = 1; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('VAlign2').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.vAlign = 2; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="spreadjs culture" content="ko-kr"/> <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="$DEMOROOT$/spread/source/data/alignment.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/jquery-1.8.2.min.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 id="Text Oriention" for="textOriention">HAlign:</label> <input type="button" value="Left" id="HAlign0" /> <input type="button" value="Center" id="HAlign1" /><br> <input type="button" value="Right" id="HAlign2" /> <input type="button" value="CenterContinues" id="HAlign3"> <input type="button" value="Distributed" id="HAlign4"> </div> <div class="option-row"> <label id="Text Oriention" for="textOriention">VAlign:</label> <input type="button" value="Top" id="VAlign0" /> <input type="button" value="Center" id="VAlign1" /><br> <input type="button" value="Bottom" id="VAlign2" /> </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; } input { width: 115px; } .option-row { font-size: 14px; padding: 5px; } label { display: block; padding-bottom: 5px; } input { padding: 4px 6px; margin-bottom: 6px; margin-right: 5px; } .paddingLabel { width: 113px; display: inline-block; text-align: center; } .paddingLabel1 { width: 50px; /* display: inline-block; */ } .paddingInput { width: 84px; } .paddingInput1 { width: 84px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }