你好,有两个办法。一种是设计模板时候行数设置多一点,这样绑定时候就不会出问题了。
另一种就是绑定后复制上一行样式。
-
- var tables = sheet.tables.all();
- if(tables){
- for (var i = 0; i < tables.length; i++){
- copyTableStyle(sheet, tables[i])
- }
- }
复制代码
- function copyTableStyle(sheet, table){
- var range = table.dataRange();
- var rowHeight = sheet.getRowHeight(range.row);
- for (var i = 1; i < range.rowCount; i++) {
- // Copy Style
- sheet.copyTo(range.row + i - 1, range.col, range.row + i, range.col, 1, range.colCount, GC.Spread.Sheets.CopyToOptions.style);
- // Copy Formula
- sheet.copyTo(range.row + i - 1, range.col, range.row + i, range.col, 1, range.colCount, GC.Spread.Sheets.CopyToOptions.formula);
- // Copy Span
- sheet.copyTo(range.row + i - 1, range.col, range.row + i, range.col, 1, range.colCount, GC.Spread.Sheets.CopyToOptions.span);
- // Set Row Height
- sheet.setRowHeight(range.row + i, rowHeight);
- //copyCustomerTableRowHeader
- sheet.copyTo(range.row + i - 1, 0, range.row + i, 0, 1, range.col, GC.Spread.Sheets.CopyToOptions.style);
- sheet.copyTo(range.row + i - 1, 0, range.row + i, 0, 1, range.col, GC.Spread.Sheets.CopyToOptions.value);
- }
复制代码
|