menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface IPivotFieldGroup - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface IPivotFieldGroup

    Represents the pivot field group in pivot field.

    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.UWP.dll
    Syntax
    public interface IPivotFieldGroup

    Properties

    EndDate

    Gets or sets the end date for pivot field grouping.

    Declaration
    DateTime EndDate { get; set; }
    Property Value
    Type
    System.DateTime
    Examples

    The following code illustrates how to get pivot field group and use it for date time grouping.

       using (ExcelEngine excelEngine = new ExcelEngine())
       {
            IApplication application = excelEngine.Excel;
            IWorkbook workbook = application.Workbooks.Open("Input.xlsx");
            IWorksheet worksheet = workbook.Worksheets[0];
    
            //Create Pivot cache with the given data range
            IPivotCache cache = workbook.PivotCaches.Add(worksheet["A1:C8"]);
    
             //Create "PivotTable1" with the cache at the specified range
            IPivotTable pivotTable = worksheet.PivotTables.Add("PivotTable1", worksheet["A1"], cache);
    
            //Get the pivot group field from pivot field.
            IPivotFieldGroup fieldGroup = pivotTable.Fields[0].FieldGroup;
    
            //Set the pivot field group end date.
            fieldGroup.EndDate = new DateTime(2023,10,3);
    
            workbook.SaveAs("Output.xlsx");
            workbook.Close();
            excelEngine.Dispose();
        }

    GroupBy

    Declaration
    PivotFieldGroupType GroupBy { get; set; }
    Property Value
    Type
    PivotFieldGroupType

    GroupInterval

    Gets or sets the grouping interval for pivot field group.This property only applicable for PivotFieldGroupType days.

    Declaration
    double GroupInterval { get; set; }
    Property Value
    Type
    System.Double
    Examples

    The following code illustrates how to get pivot field group and use it for date time grouping.

       using (ExcelEngine excelEngine = new ExcelEngine())
       {
            IApplication application = excelEngine.Excel;
            IWorkbook workbook = application.Workbooks.Open("Input.xlsx");
            IWorksheet worksheet = workbook.Worksheets[0];
    
            //Create Pivot cache with the given data range
            IPivotCache cache = workbook.PivotCaches.Add(worksheet["A1:C8"]);
    
             //Create "PivotTable1" with the cache at the specified range
            IPivotTable pivotTable = worksheet.PivotTables.Add("PivotTable1", worksheet["A1"], cache);
    
            //Get the pivot group field from pivot field.
            IPivotFieldGroup fieldGroup = pivotTable.Fields[0].FieldGroup;
    
            //To add date-time groups.
            fieldGroup.GroupBy = PivotFieldGroupType.Days;
    
            //sets the group interval for days. Only when the field is grouped on days.
            fieldGroup.GroupInterval = 3;        
    
            workbook.SaveAs("Output.xlsx");
            workbook.Close();
            excelEngine.Dispose();
        }

    StartDate

    Gets or sets the start date for pivot field grouping.

    Declaration
    DateTime StartDate { get; set; }
    Property Value
    Type
    System.DateTime
    Examples

    The following code illustrates how to get pivot field group and use it for date time grouping.

       using (ExcelEngine excelEngine = new ExcelEngine())
       {
            IApplication application = excelEngine.Excel;
            IWorkbook workbook = application.Workbooks.Open("Input.xlsx");
            IWorksheet worksheet = workbook.Worksheets[0];
    
            //Create Pivot cache with the given data range
            IPivotCache cache = workbook.PivotCaches.Add(worksheet["A1:C8"]);
    
             //Create "PivotTable1" with the cache at the specified range
            IPivotTable pivotTable = worksheet.PivotTables.Add("PivotTable1", worksheet["A1"], cache);
    
            //Get the pivot group field from pivot field.
            IPivotFieldGroup fieldGroup = pivotTable.Fields[0].FieldGroup;
    
            //Set the pivot field group start date.
            fieldGroup.StartDate = new DateTime(2023,5,20);
    
            workbook.SaveAs("Output.xlsx");
            workbook.Close();
            excelEngine.Dispose();
        }

    Extension Methods

    DateTimeExtension.ToDateTime(Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved