[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IPivotItems.Item

this Property

this[int]

Returns the IPivotItem at the specified index in the collection.

Use this property to retrieve a pivot item from the IPivotItems collection associated with a pivot field when you know its position.

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

The zero-based index of the pivot item to return.

Examples
worksheet.Range["A1:C4"].Value = new object[,] {
    {"Category", "Product", "Amount"},
    {"Beverages", "Tea", 10},
    {"Beverages", "Coffee", 20},
    {"Snacks", "Cookie", 15}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "SalesPivot");
IPivotField field = pivotTable.PivotFields["Product"];
field.Orientation = PivotFieldOrientation.RowField;
IPivotItem item = field.PivotItems[0];

this[string]

Returns the IPivotItem with the specified name from the collection.

Use this property to retrieve a pivot item from the IPivotItems collection associated with a pivot field.

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

The name of the pivot item to return.

Examples
worksheet.Range["A1:B4"].Value = new object[,] {
    {"Product", "Amount"},
    {"Apple", 100},
    {"Banana", 80},
    {"Apple", 120}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "SalesPivot");
IPivotField field = pivotTable.PivotFields["Product"];
field.Orientation = PivotFieldOrientation.RowField;
IPivotItem item = field.PivotItems["Apple"];