卡的不动,你的数据不复杂,我可能11万的数据要做几万条分组。
private void CreateGroupFooter(int colindex)
{
// 添加默认分组列
SheetView sheet = fpSpread1.ActiveSheet;
sheet.AllowGroup = true;
GroupDataModel gdm = new GroupDataModel(sheet.Models.Data);
sheet.Models.Data = gdm;
//SortInfo 构造函数 SortInfo(0, true) 中第一个参数为 用于分组的列索引。
SortInfo[] siList = new SortInfo[] { new SortInfo(colindex, true) };
gdm.Group(siList, null);
//设置默认分组
DefaultGroupFooter dgf = fpSpread1_Sheet1.DefaultGroupFooter[colindex];
ISheetDataModel dataModel = dgf.DataModel;
// 设置分组中的公式汉字显示get(5)
FarPoint.Win.Spread.CellType.TextCellType a = new TextCellType();
this.fpSpread1_Sheet1.Columns.Get(5).CellType = a;
//设置分组脚中公式
//(dataModel as IAggregationSupport).SetCellAggregationType(0, 0, AggregationType.Count);
// (dataModel as IAggregationSupport).SetCellAggregationFormat(0, 0, "数量:{0}");
(dataModel as IAggregationSupport).SetCellAggregationType(0, 5, AggregationType.Sum);
(dataModel as IAggregationSupport).SetCellAggregationFormat(0, 5, "合计:{0}");
fpSpread1.ActiveSheet.GroupFooterVisible = true;
}
这是你们之前贴给我的分组代码,麻烦你们再分析下 |