将ColumnFooter显示出来,并对相关属性做适当设置。
SetAggregationType接口可以帮助你方便的完成求和需求。
示例代码如下:- fpSpread1.Sheets[0].ColumnFooter.Visible = true;
- fpSpread1.Sheets[0].ColumnFooter.RowCount = 2;
- fpSpread1.Sheets[0].ColumnFooter.Columns[12].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left;
- fpSpread1.Sheets[0].ColumnFooter.Cells[0, 12].RowSpan = 2;
- //Value
- for (int r = 0; r < fpSpread1.Sheets[0].RowCount; r++)
- {
- for (int j = 0; j < fpSpread1.Sheets[0].ColumnCount; j++)
- {
- fpSpread1.Sheets[0].Models.Data.SetValue(r, j, j + r * fpSpread1.Sheets[0].ColumnCount);
- }
- }
- int i = 0;
- fpSpread1.Sheets[0].ColumnFooter.SetAggregationType(0,1, FarPoint.Win.Spread.Model.AggregationType.Sum);
- fpSpread1.Sheets[0].ColumnFooter.Cells[0, i].Value = "Sum";
复制代码
详情参见文档中“Displaying a Footer for Columns or Groups”章节。 |