2金币
本帖最后由 Richard.Huang 于 2023-10-20 10:11 编辑
产品:SpreadJS
版本:V16.1.2
模版配置好的列有样式,因为在模版前面又手动插入了几列,导致之前模版列头样式错乱对不上了,这个有什么api可以解决嘛
- for (let c = 0; c < tableCount; c++) {
- let dataField = table.getColumnDataField(c);
- let name = table.getColumnName(c);
- let tableColumn = new GC.Spread.Sheets.Tables.TableColumn();
- const colIndex = c + (startColumn - 1);
- const visible = activeSheet.getColumnVisible(colIndex);
- if (visible) {
- tableColumn.name(name);
- tableColumn.dataField(dataField);
- tableColumns.push(tableColumn);
- } else {
- unvisibleList.push(dataField);
- activeSheet.setColumnVisible(
- colIndex,
- true,
- GC.Spread.Sheets.SheetArea.viewport
- );
- activeSheet.setColumnVisible(
- colIndex + columnsCount,
- false,
- GC.Spread.Sheets.SheetArea.viewport
- );
- }
- }
- // 隐藏列
- console.log(unvisibleList, "unvisibleList");
- console.log(tableColumns, "tableColumns1");
- historyColumns.forEach((element) => {
- // 添加新的column
- let newTableColumn = new GC.Spread.Sheets.Tables.TableColumn();
- newTableColumn.name(element.name);
- newTableColumn.dataField(element.value);
- tableColumns.unshift(newTableColumn);
- activeSheet.setColumnWidth(0, width, GC.Spread.Sheets.SheetArea.viewpor);
- // table新增一列
- table.insertColumns(tableCount - 1, 1, true);
- });
- console.log(tableColumns, "tableColumns");
- table.bindColumns(tableColumns);
复制代码
|
最佳答案
查看完整内容
您好,这边调研了一下,因为这个样式是设置在单元格上的,因此只能是再手动调整单元格的样式来实现,请参考:
for (let i = 0; i < 5; i++) {
let style2 = activeSheet.getStyle(1, i);
activeSheet.setStyle(1, i + 4, style2);
if (i != 4) {
activeSheet.setStyle(1, i, style);
}
}
|