表单单元格头区域

Spread.Sheets允许添加多个行头/列头以便于添加自定义的行标题/列标题。

在 SpreadJS 中, 一个表单由以下四部分组成: 左上角的表单表角 列头区域 行头区域 视图区域 所以, 表单单元格头区域包含一个行头区域和一个列头区域, 并且这两个区域都可以包含多个行和列。 在一个表单头区域的行和列中, 每个单元格都拥有自动计算文字的能力, 这些文字表明行或列所在索引。如果你想知道行或者列是否显示自动计算文字,或者在指定行或者列显示自动计算文字, 可以执行以下示例代码: Spread 也提供了三种不同的自动计算文字方式: 空白, 字母, 或者数值。 你可以选择显示或隐藏行头区域或者列头区域。以下代码隐藏行头区域的所有行。
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss")); var spreadNS = GC.Spread.Sheets; var sheet = spread.getSheet(0); sheet.suspendPaint(); //Set rowHeader count and columnHeader count. sheet.setRowCount(3, spreadNS.SheetArea.colHeader); sheet.setColumnCount(3, spreadNS.SheetArea.rowHeader); //Change header "auto text". sheet.options.colHeaderAutoTextIndex = 2; sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers; //Span three columns with the origin at column header cell (0,0). sheet.addSpan(0, 0, 1, 3, GC.Spread.Sheets.SheetArea.colHeader); sheet.setValue(0, 0, "Spanned Columns", GC.Spread.Sheets.SheetArea.colHeader); sheet.setValue(1, 0, "Address", GC.Spread.Sheets.SheetArea.colHeader); sheet.getCell(-1, 0).width(140); //Add data sheet.getCell(0,0).text("1970 Napa Ct."); sheet.getCell(1,0).text("9833 Mt. Dias Blv."); sheet.getCell(2,0).text("7484 Roundtree Drive"); sheet.getCell(3,0).text("9539 Glenside Dr"); sheet.getCell(4,0).text("1226 Shoe St."); sheet.resumePaint(); /* * Show or hide the row header. */ _getElementById("chkRowHeaderVisible").addEventListener('click',function () { var sheet = spread.getActiveSheet(); sheet.options.rowHeaderVisible = this.checked; spread.invalidateLayout(); spread.repaint(); }); /* * Show or hide the column header. */ _getElementById("chkColumnHeaderVisible").addEventListener('click',function () { var sheet = spread.getActiveSheet(); sheet.options.colHeaderVisible = this.checked; spread.invalidateLayout(); spread.repaint(); }); _getElementById("btnSetAutoText").addEventListener('click',function () { var headerType = document.querySelector("input[name='headerType']:checked").value, obj=_getElementById("headerAutoTextType"), headerAutoTextType = obj.options[obj.selectedIndex].value; if (headerAutoTextType) { headerAutoTextType = spreadNS.HeaderAutoText[headerAutoTextType]; if (!(headerAutoTextType === undefined)) { switch (headerType) { case "row": sheet.options.rowHeaderAutoText = headerAutoTextType; break; case "column": sheet.options.colHeaderAutoText = headerAutoTextType; break; } } } }); }; 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/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.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="checkbox" id="chkColumnHeaderVisible" checked /> <label for="chkColumnHeaderVisible">ColumnHeaderVisible</label> </div> <div class="option-row"> <input type="checkbox" id="chkRowHeaderVisible" checked /> <label for="chkRowHeaderVisible">RowHeaderVisible</label> </div> <hr> <div class="option-row"> <label >Set the type of auto text for the headers using the following options.</label> </div> <div class="option-row"> <input type="radio" name="headerType" value="row" id="headerTypeRow" /><label for="headerTypeRow">Row</label> <input type="radio" name="headerType" value="column" id="headerTypeColumn" checked="checked" /><label for="headerTypeColumn">Column</label> </div> <div class="option-row"> <label for="headerAutoTextType" style="display:inline-block;">Header Auto Text type: </label> </div> <select id="headerAutoTextType" style="padding-left: 5px"> <option value="blank">Blank</option> <option value="letters" selected="selected">Letters</option> <option value="numbers">Numbers</option> </select> <input type="button" id="btnSetAutoText" value="Set" /> </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=button] { margin-top: 6px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }