[]
Gets the pivot field at the specified index.
Use this property to retrieve a single IPivotField from the
IPivotFields collection by position.
IPivotField this[int index] { get; }
ReadOnly Default Property Item(index As Integer) As IPivotField
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the pivot field to retrieve from the collection. |
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;
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | if |
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.
IPivotField this[string name] { get; }
ReadOnly Default Property Item(name As String) As IPivotField
| Type | Name | Description |
|---|---|---|
| string | name | The name of the PivotTable field to retrieve. This value must match the field name in the collection. |
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"];