[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.ICalculatedFields.Item

this Property

this[int]

Gets the calculated field at the specified index.

Use this property to retrieve a calculated field from the collection returned by CalculatedFields.

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

The index of the calculated field.

Examples
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];

this[string]

Gets the calculated field by name.

Use this property to retrieve a calculated field from the collection returned by CalculatedFields.

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

The name of the calculated field to retrieve.

Examples
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"];
Exceptions
Type Condition
ArgumentException

if no calculated field matches fieldName.