回复 7楼victorysoft的帖子
以下为主要代码,首先需要设置分组和分组使用的公司,然后在for循环中更改显示的内容:
- //设置默认分组
- DefaultGroupFooter groupFooter = fpSpread1.Sheets[0].DefaultGroupFooter[4];
- ISheetDataModel dataModel = groupFooter.DataModel;
- //设置分组脚中公式
- (dataModel as IAggregationSupport).SetCellAggregationType(0, 3, AggregationType.Count);
- (dataModel as IAggregationSupport).SetCellAggregationFormat(0, 3, "数量:{0}");
- (dataModel as IAggregationSupport).SetCellAggregationType(0, 4, AggregationType.Sum);
- (dataModel as IAggregationSupport).SetCellAggregationFormat(0, 4, "合计:{0}能否进行修改?");
- fpSpread1.ActiveSheet.GroupFooterVisible = true;
- FarPoint.Win.Spread.FpSpread spread = this.fpSpread1;
- FarPoint.Win.Spread.Model.GroupDataModel gm;
- //更改分组 Text 内容
- if (spread.ActiveSheet.Models.Data.GetType() == typeof(FarPoint.Win.Spread.Model.GroupDataModel))
- {
- gm = (FarPoint.Win.Spread.Model.GroupDataModel)spread.Sheets[0].Models.Data;
- for (int i = 0; i < gm.Groups.Count; i++)
- {
- try
- {
- FarPoint.Win.Spread.Model.Group g;
- g = gm.Groups[i] as FarPoint.Win.Spread.Model.Group;
- int row = g.Rows.Count;
- if (g != null)
- {
- g.Text = g.GroupFooter.DataModel.GetValue(0, 4).ToString();
- }
- }
- catch (Exception)
- {
- }
- }
- }
复制代码 |