找回密码
 立即注册

QQ登录

只需一步,快速开始

anyOneCode

注册会员

3

主题

26

帖子

71

积分

注册会员

积分
71
最新发帖
anyOneCode
注册会员   /  发表于:2023-9-22 09:19  /   查看:809  /  回复:3
  1. let tableCount = table.range().colCount;
  2.         let columnsCount = historyColumns.length;
  3.         activeSheet.addColumns(tableCount, columnsCount);
  4.         let width = activeSheet.getColumnWidth(
  5.           tableCount,
  6.           GC.Spread.Sheets.SheetArea.viewport
  7.         );

  8.         let tableColumns: any = [];
  9.         let unvisibleList: any = [];
  10.         // 获取table原有column
  11.         for (let c = 0; c < tableCount; c++) {
  12.           let dataField = table.getColumnDataField(c);
  13.           let name = table.getColumnName(c);
  14.           let tableColumn = new GC.Spread.Sheets.Tables.TableColumn();
  15.           const colIndex = c + (startColumn - 1);
  16.           const visible = activeSheet.getColumnVisible(colIndex);
  17.           if (visible) {
  18.             tableColumn.name(name);
  19.             tableColumn.dataField(dataField);
  20.             tableColumns.push(tableColumn);
  21.           } else {
  22.             unvisibleList.push(dataField);
  23.             activeSheet.setColumnVisible(
  24.               colIndex,
  25.               true,
  26.               GC.Spread.Sheets.SheetArea.viewport
  27.             );
  28.             activeSheet.setColumnVisible(
  29.               colIndex + columnsCount,
  30.               false,
  31.               GC.Spread.Sheets.SheetArea.viewport
  32.             );
  33.           }
  34.         }
  35.         // 隐藏列
  36.         console.log(unvisibleList,'unvisibleList');
  37.         console.log(tableColumns, "tableColumns1");
  38.         historyColumns.forEach((element) => {
  39.           // 添加新的column
  40.           let newTableColumn = new GC.Spread.Sheets.Tables.TableColumn();
  41.           newTableColumn.name(element.name);
  42.           newTableColumn.dataField(element.value);
  43.           tableColumns.unshift(newTableColumn);
  44.           activeSheet.setColumnWidth(
  45.             0,
  46.             width,
  47.             GC.Spread.Sheets.SheetArea.viewpor
  48.           );
  49.           // table新增一列
  50.           table.insertColumns(tableCount - 1, 1, true);
  51.         });
  52.         console.log(tableColumns, "tableColumns");
  53.         table.bindColumns(tableColumns);
复制代码
  1. const historyColumns = [
  2.   {
  3.     name: "处理人",
  4.     value: "process_user",
  5.   },
  6.   {
  7.     name: "处理时间",
  8.     value: "process_time",
  9.   },
  10.   {
  11.     name: "处理节点",
  12.     value: "process_node",
  13.   },
  14.   {
  15.     name: "数据类型",
  16.     value: "history_type",
  17.   },
  18. ];
复制代码


微信图片_20230922091821.png

3 个回复

倒序浏览
anyOneCode
注册会员   /  发表于:2023-9-22 09:21:35
沙发
  1. // 历史记录列头合并
  2.         activeSheet.addRows(0, 1);
  3.         let style = new GC.Spread.Sheets.Style();
  4.         style.backColor = "#5b9bd5";
  5.         style.foreColor = "White";
  6.         // style.isVerticalText = 'true';
  7.         style.hAlign = GC.Spread.Sheets.HorizontalAlign.center;
  8.         style.vAlign = GC.Spread.Sheets.VerticalAlign.center;
  9.         activeSheet.setStyle(0, 1, style, GC.Spread.Sheets.SheetArea.viewport);
  10.         activeSheet.setStyle(0, 0, style, GC.Spread.Sheets.SheetArea.viewport);

  11.         activeSheet.addSpan(0, 1, 1, 3);
  12.         activeSheet.addSpan(0, 0, 2, 1);

  13.         // activeSheet.addSpan(0, 0, 1, tableColumns.length - 3);

  14.         // activeSheet.setValue(0, 3, '基本信息');
  15.         activeSheet
  16.           .getCell(0, 1)
  17.           .text("处理记录")
  18.           .font("bold normal 15px normal");
  19.         activeSheet
  20.           .getCell(0, 0)
  21.           .text("数据类型")
  22.           .font("bold normal 15px normal");

  23.         activeSheet.setValue(0, 1, "处理记录");
  24.         activeSheet.setValue(0, 0, "数据类型");
复制代码
前4列列头合并代码
回复 使用道具 举报
anyOneCode
注册会员   /  发表于:2023-9-22 09:25:31
板凳
json文件

历史记录.zip

6.02 KB, 下载次数: 17

回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-9-22 11:09:04
地板
本帖最后由 Joestar.Xu 于 2023-9-22 11:12 编辑

您好,后续我将在这个金牌帖子中跟进:https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=187197
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部