- let tableCount = table.range().colCount;
- let columnsCount = historyColumns.length;
- activeSheet.addColumns(tableCount, columnsCount);
- let width = activeSheet.getColumnWidth(
- tableCount,
- GC.Spread.Sheets.SheetArea.viewport
- );
- let tableColumns: any = [];
- let unvisibleList: any = [];
- // 获取table原有column
- 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);
复制代码- const historyColumns = [
- {
- name: "处理人",
- value: "process_user",
- },
- {
- name: "处理时间",
- value: "process_time",
- },
- {
- name: "处理节点",
- value: "process_node",
- },
- {
- name: "数据类型",
- value: "history_type",
- },
- ];
复制代码
|
-
|