你可以将指定的行或者列组合,

本操作将会在表头创建一个额外的区域来显示组合的大纲。点击该区域的加号或者减号来展开或者收起分组。

使用 group 方法来创建分组。

行分组区域在行标题的左侧,列分组的区域在列标题的顶端。

级别按钮中的数字显示了分组有几个层级。

点击级别按钮来展开相应的层级。

你可以使用 showRowOutline 或者 showColumnOutline 显示或者隐藏分组。

你可以使用 unGroup 来取消分组



示例代码

以下代码创建了一个列分组和一个行分组。

activeSheet.setRowCount(34);
activeSheet.setValue(0,0,"Western");
activeSheet.setValue(0,1,"Western");
activeSheet.setValue(0,2,"Western");
activeSheet.setValue(1,0,"A");
activeSheet.setValue(1,1,"B");
activeSheet.setValue(1,2,"C");
activeSheet.setValue(2,0,"A");
activeSheet.setValue(2,1,"B");
activeSheet.setValue(2,2,"C");
activeSheet.rowOutlines.group(0,2);
activeSheet.columnOutlines.group(0,1);
//activeSheet.rowOutlines.expand(0,false);
//activeSheet.columnOutlines.expand(0,false);
spread.invalidateLayout();
spread.repaint();

示例代码

以下代码展示了分组方向。

activeSheet.rowOutlines.group(3,2);
activeSheet.columnOutlines.group(4,1);
activeSheet.rowOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.backward);
activeSheet.columnOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.forward);
spread.invalidateLayout();
spread.repaint();

示例代码

以下代码使用 execute 方法指定了分组时的动作。

var spread = new GC.Spread.Sheets.Workbook($("#ss")[0]);
var activeSheet = spread.getActiveSheet();
spread.commandManager().execute({cmd: "outlineRow", sheetName: activeSheet.name(), index: 4, count: 3});

示例代码

以下代码演示了如何查找一个分组。

activeSheet.rowOutlines.group(0,5);
var rgi = activeSheet.rowOutlines.find(1, 0);
rgi.state(GC.Spread.Sheets.Outlines.OutlineState.collapsed);
spread.invalidateLayout();
spread.repaint();

示例代码

以下代码设使用了 showRowOutline 和 showColumnOutline 方法

activeSheet.showRowOutline(true);
activeSheet.rowOutlines.group(0, 2);
activeSheet.showColumnOutline(true);
activeSheet.columnOutlines.group(0, 2);
//activeSheet.rowOutlines.ungroup(0, 2);
//activeSheet.columnOutlines.ungroup(0, 2);
spread.invalidateLayout();
spread.repaint();

另见

expandGroup Method
expand Method
group Method
Workbook Method