Spread Windows Forms 6.0 Product Documentation
SetCellAggregationType Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread.Model Namespace > IAggregationSupport Interface : SetCellAggregationType Method


row
Cell row
col
Cell column
type
Aggregation type

Glossary Item Box

Set aggregation type for cell.

Syntax

Visual Basic (Declaration) 
Sub SetCellAggregationType( _
   ByVal row As Integer, _
   ByVal col As Integer, _
   ByVal type As AggregationType _
) 
Visual Basic (Usage)Copy Code
Dim instance As IAggregationSupport
Dim row As Integer
Dim col As Integer
Dim type As AggregationType
 
instance.SetCellAggregationType(row, col, type)
C# 
void SetCellAggregationType( 
   int row,
   int col,
   AggregationType type
)

Parameters

row
Cell row
col
Cell column
type
Aggregation type

Example

This example puts a sum in a group footer.
C#Copy Code
private void Form1_Load(object sender, EventArgs e)
 {
  fpSpread1.Sheets[0].RowCount = 8;
  fpSpread1.Sheets[0].ColumnCount = 15;
  fpSpread1.Sheets[0].GroupBarInfo.Visible = true;
  fpSpread1.Sheets[0].AllowGroup = true;
  fpSpread1.Sheets[0].GroupFooterVisible = true;
  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";
 }

private void fpSpread1_Grouped(object sender, EventArgs e)
 {
  FarPoint.Win.Spread.Model.GroupDataModel gdm;
  gdm = (FarPoint.Win.Spread.Model.GroupDataModel)fpSpread1.ActiveSheet.Models.Data;
  gdm.GroupFooterVisible = true;
  FarPoint.Win.Spread.Model.Group g1 = (FarPoint.Win.Spread.Model.Group)gdm.Groups[1];           
  ((FarPoint.Win.Spread.Model.IAggregationSupport)g1.GroupFooter.DataModel).SetCellAggregationType(0, 0, FarPoint.Win.Spread.Model.AggregationType.Sum);
  fpSpread1.ActiveSheet.Models.Data = gdm;
  }
Visual BasicCopy Code
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      FpSpread1.Sheets(0).RowCount = 8
      FpSpread1.Sheets(0).ColumnCount = 15
      FpSpread1.Sheets(0).GroupBarInfo.Visible = True
      FpSpread1.Sheets(0).AllowGroup = True
      FpSpread1.Sheets(0).GroupFooterVisible = True
      FpSpread1.Sheets(0).ColumnFooter.Visible = True
      FpSpread1.Sheets(0).ColumnFooter.RowCount = 2
FpSpread1.Sheets(0).ColumnFooter.Columns(12).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left
      'Value
      Dim r As Integer
      Dim j As Integer
      For r = 0 To FpSpread1.Sheets(0).RowCount
          For j = 0 To FpSpread1.Sheets(0).ColumnCount
              FpSpread1.Sheets(0).Models.Data.SetValue(r, j, j + r * FpSpread1.Sheets(0).ColumnCount)
          Next j
      Next r
      Dim i As Integer
      i = 0
      FpSpread1.Sheets(0).ColumnFooter.SetAggregationType(0, 1, FarPoint.Win.Spread.Model.AggregationType.Sum)
      FpSpread1.Sheets(0).ColumnFooter.Cells(0, i).Value = "Sum"
  End Sub

  Private Sub FpSpread1_Grouped(ByVal sender As Object, ByVal e As System.EventArgs) Handles FpSpread1.Grouped
      Dim gdm As FarPoint.Win.Spread.Model.GroupDataModel
      Dim g1 As FarPoint.Win.Spread.Model.Group
      gdm = FpSpread1.Sheets(0).Models.Data
      gdm.GroupFooterVisible = True
      g1 = gdm.Groups(1)
      CType(g1.GroupFooter.DataModel, FarPoint.Win.Spread.Model.IAggregationSupport).SetCellAggregationType(0, 0, FarPoint.Win.Spread.Model.AggregationType.Sum)
      FpSpread1.ActiveSheet.Models.Data = gdm
  End Sub

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.