File Formats

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PivotDataFields

    Show / Hide Table of Contents

    Class PivotDataFields

    Represents pivot table data fields collection.

    Inheritance
    System.Object
    Syncfusion.XlsIO.Implementation.Collections.CollectionBase<PivotDataField>
    Syncfusion.XlsIO.Implementation.Collections.CollectionBaseEx<PivotDataField>
    PivotDataFields
    Implements
    System.Collections.Generic.IList<PivotDataField>
    System.Collections.Generic.ICollection<PivotDataField>
    System.Collections.Generic.IEnumerable<PivotDataField>
    System.Collections.IEnumerable
    IParentApplication
    ICloneParent
    IPivotDataFields
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.XlsIO.Implementation.PivotTables
    Assembly: Syncfusion.XlsIO.Base.dll
    Syntax
    public class PivotDataFields : CollectionBaseEx<PivotDataField>, IList<PivotDataField>, ICollection<PivotDataField>, IEnumerable<PivotDataField>, IEnumerable, IParentApplication, ICloneParent, IPivotDataFields

    Constructors

    PivotDataFields(IApplication, Object)

    Initializes new instance of pivot table data fields collection.

    Declaration
    public PivotDataFields(IApplication application, object parent)
    Parameters
    Type Name Description
    IApplication application

    Application object for the new instance.

    System.Object parent

    Parent object for the new instance.

    Methods

    Add(IPivotField, String, PivotSubtotalTypes)

    Adds a new data field to the PivotDataField collection.

    Declaration
    public IPivotDataField Add(IPivotField field, string name, PivotSubtotalTypes subtotal)
    Parameters
    Type Name Description
    IPivotField field

    The parent field to use.

    System.String name

    The name for the new data field.

    PivotSubtotalTypes subtotal

    The subtotal function for the new data field.

    Returns
    Type Description
    IPivotDataField

    Returns a pivot data field.

    Examples

    Following code snippet illustrates how to add a pivot data field to the pivot table.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IWorksheet worksheet = workbook.Worksheets[0];
    
    // Create Pivot cache with the given data range
    IPivotCache cache = workbook.PivotCaches.Add(worksheet["A1:H50"]);  
    //Create "PivotTable1" with the cache at the specified range
    IPivotTable pivotTable = worksheet.PivotTables.Add("PivotTable1", worksheet["A1"], cache);
    //Add Pivot table fields (Row and Column fields)
    pivotTable.Fields[2].Axis = PivotAxisTypes.Row;
    pivotTable.Fields[6].Axis = PivotAxisTypes.Row;
    pivotTable.Fields[3].Axis = PivotAxisTypes.Column;
    
    //Add data field
    IPivotField field = pivotTable.Fields[5];
    pivotTable.DataFields.Add(field, "Sum", PivotSubtotalTypes.Sum);

    Explicit Interface Implementations

    IPivotDataFields.get_Item(Int32)

    Declaration
    IPivotDataField IPivotDataFields.get_Item(int index)
    Parameters
    Type Name Description
    System.Int32 index
    Returns
    Type Description
    IPivotDataField

    IPivotDataFields.Item[Int32]

    Gets a pivot data field with the specified index from the collection. Read-only.

    Declaration
    IPivotDataField IPivotDataFields.this[] { get; }
    Parameters
    Type Name Description
    System.Int32 index

    Zero-based index of the data field to return.

    Returns
    Type Description
    IPivotDataField

    Implements

    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    IParentApplication
    ICloneParent
    IPivotDataFields
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved