eas之kdtable分组

  • 如何指定是否要进行数据分组以及对哪些列进行分组
// 指定KDTable要进行数据分组
table.getGroupManager().setGroup(true);
// 指明要对012三列进行分组
table.getColumn(0).setGroup(true);
table.getColumn(1).setGroup(true);
table.getColumn(2).setGroup(true);
  • 如何指定是否根据分组进行单元融合
// 指明要对012列的分组进行单元融合
table.getColumn(0).setMergeable(true);
table.getColumn(1).setMergeable(true);
table.getColumn(2).setMergeable(true);
  • 如何指定是否要做统计,对哪些分组进行统计,以及是否做总计
// 指明分组后要做总计
table.getGroupManager().setTotalize(true);
// 指明要对第0列进行统计
table.getColumn(0).setStat(true);
// 指明要对第1列进行统计
table.getColumn(1).setStat(true);
// 指明要对第2列进行统计
table.getColumn(2).setStat(true);
  • 如何指定统计行的位置
// 统计行的位置处于数据行的下方
table.getGroupManager().setOrientation(KDTStyleConstants.DOWN);
// 统计行的位置处于数据行的上方
table.getGroupManager().setOrientation(KDTStyleConstants.UP);
  • 如何定义统计行显示的内容和样式
// 定义两个变量
IRow row0;
KDTDataStyle ds;
// 设置统计行模板
// 获取总计行的模板(总计行的分组级别为-1
row0 = (IRow)table.getGroupManager().getStatRowTemplate(-1);
// 修改总计行的背景色为蓝色
row0.getStyleAttributes().getInterior().setBackground(Color.blue);
// 设置总计行第0个单元的值
row0.getCell(0).setValue("总计");
// 设置总计行第3个单元的统计公式
row0.getCell(3). setExpressions(KDTGroupManager.STAT_SUM);
        
// 获取第0级统计的模板
row0 = (IRow)table.getGroupManager().getStatRowTemplate(0);
// 设置第0级统计行的背景色
row0.getStyleAttributes().getInterior().setBackground(Color.green);
// 设置第0级统计行的第0个单元的值
row0.getCell(0).setValue("平均值");
// 设置第0级统计行第3个单元的统计公式
row0.getCell(3).setExpressions(KDTGroupManager.STAT_AVERAGE);
        
// 获取第1级统计的模板
row0 = (IRow)table.getGroupManager().getStatRowTemplate(1);
// 设置第1级统计行的背景色
row0.getStyleAttributes().getInterior().setBackground(Color.cyan);
// 设置第1级统计行的第0个单元的值
row0.getCell(1).setValue("最大值");
// 设置第1级统计行第3个单元的统计公式
row0.getCell(3).setExpressions(KDTGroupManager.STAT_MAX);
// 获取第2级统计的模板
row0 = (IRow)table.getGroupManager().getStatRowTemplate(2);
// 设置第2级统计行的背景色
row0.getStyleAttributes().getInterior().setBackground(Color.darkGray);
// 设置第2级统计行的第0个单元的值
row0.getCell(2).setValue("最小值");
// 设置第2级统计行第3个单元的统计公式
row0.getCell(3).setExpressions(KDTGroupManager.STAT_MIN);
  • 如何根据分组统计的情况生成树
// 生成树
table.getGroupManager().toTreeColumn();
// 重新调整布局并刷新
table.reLayoutAndPaint();

猜你喜欢

转载自www.cnblogs.com/luojiabao/p/10963686.html
EAS
今日推荐