Class PivotFormatConditionCollection
Contents
[
Hide
]PivotFormatConditionCollection class
Represents PivotTable Format Conditions.
public class PivotFormatConditionCollection : CollectionBase<PivotFormatCondition>
Properties
Name | Description |
---|---|
Capacity { get; set; } | |
Count { get; } | |
Item { get; } | Gets the pivot FormatCondition object at the specific index. |
Item { get; set; } |
Methods
Name | Description |
---|---|
Add() | Adds a pivot FormatCondition to the collection. |
BinarySearch(PivotFormatCondition) | |
BinarySearch(PivotFormatCondition, IComparer<PivotFormatCondition>) | |
BinarySearch(int, int, PivotFormatCondition, IComparer<PivotFormatCondition>) | |
Clear() | |
Contains(PivotFormatCondition) | |
CopyTo(PivotFormatCondition[]) | |
CopyTo(PivotFormatCondition[], int) | |
CopyTo(int, PivotFormatCondition[], int, int) | |
Exists(Predicate<PivotFormatCondition>) | |
Find(Predicate<PivotFormatCondition>) | |
FindAll(Predicate<PivotFormatCondition>) | |
FindIndex(Predicate<PivotFormatCondition>) | |
FindIndex(int, Predicate<PivotFormatCondition>) | |
FindIndex(int, int, Predicate<PivotFormatCondition>) | |
FindLast(Predicate<PivotFormatCondition>) | |
FindLastIndex(Predicate<PivotFormatCondition>) | |
FindLastIndex(int, Predicate<PivotFormatCondition>) | |
FindLastIndex(int, int, Predicate<PivotFormatCondition>) | |
GetEnumerator() | |
IndexOf(PivotFormatCondition) | |
IndexOf(PivotFormatCondition, int) | |
IndexOf(PivotFormatCondition, int, int) | |
LastIndexOf(PivotFormatCondition) | |
LastIndexOf(PivotFormatCondition, int) | |
LastIndexOf(PivotFormatCondition, int, int) | |
RemoveAt(int) |
Examples
[C#]
namespace Demos
{
using Aspose.Cells;
using Aspose.Cells.Pivot;
using System;
using System.Drawing;
public class PivotFormatConditionCollectionDemo
{
public static void PivotFormatConditionCollectionExample()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add some data to the worksheet
worksheet.Cells[0, 0].Value = "Fruit";
worksheet.Cells[1, 0].Value = "Apple";
worksheet.Cells[2, 0].Value = "Banana";
worksheet.Cells[3, 0].Value = "Cherry";
worksheet.Cells[4, 0].Value = "Date";
worksheet.Cells[0, 1].Value = "Year";
worksheet.Cells[1, 1].Value = 2020;
worksheet.Cells[2, 1].Value = 2020;
worksheet.Cells[3, 1].Value = 2021;
worksheet.Cells[4, 1].Value = 2021;
worksheet.Cells[0, 2].Value = "Amount";
worksheet.Cells[1, 2].Value = 50;
worksheet.Cells[2, 2].Value = 60;
worksheet.Cells[3, 2].Value = 70;
worksheet.Cells[4, 2].Value = 80;
// Add a pivot table to the worksheet
PivotTableCollection pivotTables = worksheet.PivotTables;
int pivotIndex = pivotTables.Add("=Sheet1!A1:C5", "E5", "PivotTable1");
PivotTable pivotTable = pivotTables[pivotIndex];
// Configure the pivot table
pivotTable.AddFieldToArea(PivotFieldType.Row, "Fruit");
pivotTable.AddFieldToArea(PivotFieldType.Column, "Year");
pivotTable.AddFieldToArea(PivotFieldType.Data, "Amount");
// Add a pivot format condition
PivotFormatConditionCollection pivotFormatConditions = pivotTable.PivotFormatConditions;
int formatConditionIndex = pivotFormatConditions.Add();
PivotFormatCondition pivotFormatCondition = pivotFormatConditions[formatConditionIndex];
// Configure the format condition
FormatConditionCollection formatConditions = pivotFormatCondition.FormatConditions;
formatConditions.AddArea(pivotTable.DataBodyRange);
int conditionIndex = formatConditions.AddCondition(FormatConditionType.CellValue);
FormatCondition formatCondition = formatConditions[conditionIndex];
formatCondition.Formula1 = "60";
formatCondition.Operator = OperatorType.GreaterOrEqual;
formatCondition.Style.BackgroundColor = Color.Yellow;
// Save the workbook
workbook.Save("PivotFormatConditionCollectionExample.xlsx");
}
}
}
See Also
- class CollectionBase<T>
- class PivotFormatCondition
- namespace Aspose.Cells.Pivot
- assembly Aspose.Cells