[]
Gets the calculated field at the specified index.
Use this property to retrieve a calculated field from the collection returned by CalculatedFields.
IPivotField this[int index] { get; }
ReadOnly Default Property Item(index As Integer) As IPivotField
| Type | Name | Description |
|---|---|---|
| int | index | The index of the calculated field. |
worksheet.Range["A1:B3"].Value = new object[,] {
{"Product", "Amount"},
{"Bike", 100},
{"Bike", 200}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B3"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"]);
pivotTable.CalculatedFields.Add("Tax", "=Amount*0.1");
IPivotField field = pivotTable.CalculatedFields[0];
Gets the calculated field by name.
Use this property to retrieve a calculated field from the collection returned by CalculatedFields.
IPivotField this[string fieldName] { get; }
ReadOnly Default Property Item(fieldName As String) As IPivotField
| Type | Name | Description |
|---|---|---|
| string | fieldName | The name of the calculated field to retrieve. |
worksheet.Range["A1:B4"].Value = new object[,] {
{"Product", "Amount"},
{"Apple", 120},
{"Orange", 90},
{"Apple", 80}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"]);
pivotTable.CalculatedFields.Add("Tax", "=Amount*0.1");
IPivotField field = pivotTable.CalculatedFields["Tax"];
| Type | Condition |
|---|---|
| ArgumentException | if no calculated field matches |