PivotTable Class

NReco.PivotData Class Library Documentation
Represents 2D Pivot Table view for multidimensional array (IPivotData).
Inheritance Hierarchy

SystemObject
  NReco.PivotDataPivotTable

Namespace:  NReco.PivotData
Assembly:  NReco.PivotData (in NReco.PivotData.dll) Version: 1.4.1
Syntax

public class PivotTable : IPivotTable

The PivotTable type exposes the following members.

Constructors

  NameDescription
Public methodPivotTable(String, String, IPivotData)
Initializes a new instance of PivotTable instance by specified PivotData
Public methodPivotTable(String, String, IPivotData, IComparerValueKey, IComparerValueKey)
Initializes a new instance of PivotTable instance by specified PivotData
Top
Properties

  NameDescription
Public propertyColumnKeys
Dimension keys that represent columns of the pivot table
Public propertyColumns
Dimensions used for building columns of the pivot table
Public propertyItem
Gets aggregator for specified row and column indexes
Public propertyPivotData
Gets the IPivotData used for building pivot table.
Public propertyPreserveGroupOrder
Public propertyRowKeys
Dimension keys that represent rows of the pivot table
Public propertyRows
Dimensions used for building rows of the pivot table
Public propertyTotalsCache
Controls totals cache usage (true by default).
Public propertyValuesComparer
This comparer is used when table is ordered by values. Null by default (in this case default comparer is used).
Top
Methods

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodGetValue
Gets value for specified row and column keys.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSortColumnKeys(NullableInt32, ListSortDirection)
Sort columns by specified row values.
Public methodSortColumnKeys(NullableInt32, Int32, ListSortDirection)
Sort columns by specified row values
Public methodSortColumnKeysByRowKey
Sort columns by specified row key.
Protected methodSortKeys
Performs inital ordering of pivot table rows/columns keys
Public methodSortRowKeys(NullableInt32, ListSortDirection)
Sort rows by specified column values.
Public methodSortRowKeys(NullableInt32, Int32, ListSortDirection)
Sort rows by specified column values.
Public methodSortRowKeysByColumnKey
Sort rows by specified column key.
Public methodToString (Inherited from Object.)
Top
Remarks

PivotTable provides an API for building pivot table report from multidimensional array represented by IPivotData instance. Configuration is rather simple: all it needs is a list of dimensions for building rows and columns (it may use only subset of dimensions available in specified PivotData instance). Also it supports table sorting by column or row values (or by totals).
Examples

The following code snippet illustrates how to use PivotTable:
PivotData pvtData; 
var pvtTbl = new PivotTable(
    new [] {"country", "city" }, // rows are cities grouped by country
    new [] {"company"},  // columns are companines
    pvtData);
for (var r=0; r<pvtTbl.RowKeys.Length; r++) {
    for (var c=0; c<pvtTbl.ColumnKeys.Length; c++) {
        Console.Write("{0}\t", pvtTbl[r,c].Value);
    }
    Console.WriteLine();
}
See Also

Reference