[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.ICalculatedItems.Item

this Property

this[int]

Gets the IPivotItem at the specified index.

Use this property to retrieve a calculated item from the collection returned by CalculatedItems().

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 calculated item.

Examples
worksheet.Range["A1:B4"].Value = new object[,] {
    {"Country", "Amount"},
    {"France", 100},
    {"Germany", 200},
    {"Canada", 150}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "PivotTable1");
pivotTable.PivotFields["Country"].Orientation = PivotFieldOrientation.RowField;
ICalculatedItems calculatedItems = pivotTable.PivotFields["Country"].CalculatedItems();
calculatedItems.Add("Europe", "=France+Germany");
IPivotItem item = calculatedItems[0];

this[string]

Gets the IPivotItem item by name.

Use this property to retrieve a calculated item from the ICalculatedItems collection of a pivot field.

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

The name of the calculated item to retrieve.

Examples
worksheet.Range["A1:B4"].Value = new object[,] {
    {"Status", "Amount"},
    {"Pending", 100},
    {"Backorder", 200},
    {"Shipped", 300}
};
IWorksheet pivotSheet = workbook.Worksheets.Add();
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = pivotSheet.PivotTables.Add(pivotCache, pivotSheet.Range["A1"]);
pivotTable.PivotFields["Status"].Orientation = PivotFieldOrientation.RowField;
ICalculatedItems calculatedItems = pivotTable.PivotFields["Status"].CalculatedItems();
calculatedItems.Add("Open Orders", "=Pending+Backorder");
IPivotItem item = calculatedItems["Open Orders"];