[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IPivotFields.Item

this Property

this[int]

Gets the pivot field at the specified index.

Use this property to retrieve a single IPivotField from the IPivotFields collection by position.

Declaration
IPivotField this[int index] { get; }
ReadOnly Default Property Item(index As Integer) As IPivotField
Parameters
Type Name Description
int index

The zero-based index of the pivot field to retrieve from the collection.

Examples
worksheet.Range["A1:B5"].Value = new object[,] {
    {"Category", "Amount"},
    {"Fruit", 120},
    {"Fruit", 80},
    {"Vegetables", 95},
    {"Vegetables", 60}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B5"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "SalesPivot");
IPivotField field = pivotTable.PivotFields[0];
field.Orientation = PivotFieldOrientation.RowField;
Exceptions
Type Condition
ArgumentOutOfRangeException

if index is outside the valid range of the collection.

this[string]

Gets the IPivotField with the specified name from this collection.

Use this property to retrieve a PivotTable field by its display name in the current IPivotFields collection.

Declaration
IPivotField this[string name] { get; }
ReadOnly Default Property Item(name As String) As IPivotField
Parameters
Type Name Description
string name

The name of the PivotTable field to retrieve. This value must match the field name in the collection.

Examples
worksheet.Range["A1:C4"].Value = new object[,] {
    {"Region", "Product", "Amount"},
    {"East", "Apple", 120},
    {"West", "Apple", 80},
    {"East", "Orange", 90}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "SalesPivot");
IPivotField field = pivotTable.PivotFields["Product"];