拆分调整大小

SpreadJS支持拆分调整大小。 可以在调整列大小时按住Ctrl键来激活拆分调整大小。

简介 拆分调整大小允许用户改变两个相邻列或行的宽度,作为两者之间的split。 例如,调整A列的大小也会调整B列的大小,但保持其他列的大小不变,防止在调整其他行/列的大小时,重要数据被移出可视区域。 当创建精确的报告布局,并需要在不影响整体布局的情况下进行小的调整时,这个功能很有用。 您可以将ResizeMode设置为split以对行和列启用此功能。 另外,在调整大小时使用Ctrl键也可以启用Split Resize。
window.onload = function() { var spread = new GC.Spread.Sheets.Workbook(_getElementById('ss'), { sheetCount: 1 }); initSpread(spread); }; function initSpread(spread) { var sheet = spread.getActiveSheet(); sheet.suspendPaint(); var rowResizeMode = _getElementById("rowResizeMode"); rowResizeMode.addEventListener("change", function () { spread.options.rowResizeMode = parseInt(rowResizeMode.options[rowResizeMode.selectedIndex].value, 10); }); var columnResizeMode = _getElementById("columnResizeMode"); _getElementById("columnResizeMode").addEventListener("change", function () { spread.options.columnResizeMode = parseInt(columnResizeMode.options[columnResizeMode.selectedIndex].value, 10); }); sheet.resumePaint(); } function _getElementById(id){ return document.getElementById(id); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="zh-cn" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/data.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"> <p>Change the Resize Mode to Split to enable this feature. </p> <p>For example, set Column Resize Mode to split. Now change the width of column A. Column B will automatically resize while the remaining columns will stay the same size.</p> <label for="columnResizeMode">Column Resize Mode</label> <select id="columnResizeMode"> <option value="0">normal</option> <option value="1">split</option> </select> </div> <div class="option-row"> <label for="rowResizeMode">Row Resize Mode</label> <select id="rowResizeMode"> <option value="0">normal</option> <option value="1">split</option> </select> </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; margin-top: 10px; } label { margin-bottom: 6px; } input { padding: 4px 6px; } input[type=number] { width: 40px; } hr { border-color: #fff; opacity: .2; margin-top: 20px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }