[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IPivotField.Ungroup

Ungroup Method

Ungroup()

Removes grouping from the pivot field.

Declaration
void Ungroup()
Sub Ungroup()
Examples
Workbook workbook = new Workbook();
workbook.Options.Data.AutomaticGroupDateTimeInPivotTable = false;
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Range["A1:C5"].Value = new object[,]
{
    { "Order Date", "Region", "Amount" },
    { new DateTime(2024, 1, 5), "East", 10 },
    { new DateTime(2024, 1, 18), "West", 20 },
    { new DateTime(2024, 2, 2), "East", 30 },
    { new DateTime(2024, 2, 25), "West", 40 }
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C5"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "PivotTable1");
IPivotField orderDateField = pivotTable.PivotFields["Order Date"];
orderDateField.Orientation = PivotFieldOrientation.RowField;
pivotTable.PivotFields["Amount"].Orientation = PivotFieldOrientation.DataField;
PivotFieldDateGroupOptions options = new PivotFieldDateGroupOptions
{
    GroupBy = PivotFieldDateGroupBy.Months
};
orderDateField.Group(options);
orderDateField.Ungroup();