[]
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.
IPivotItem this[int index] { get; }
ReadOnly Default Property Item(index As Integer) As IPivotItem
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the pivot item to return. |
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];
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.
IPivotItem this[string name] { get; }
ReadOnly Default Property Item(name As String) As IPivotItem
| Type | Name | Description |
|---|---|---|
| string | name | The name of the pivot item to return. |
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"];