[]
Iterable<IPivotItem>IPivotItem objects that represent all the calculated items in the specified PivotTable report.Use this interface to access, add, and remove calculated items for a pivot field. Obtain an instance from IPivotField.getCalculatedItems().
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Product", "Category", "Amount"},
{"Apple", "Fruit", 120},
{"Banana", "Fruit", 80},
{"Bran", "Snack", 60}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
ICalculatedItems calculatedItems = pivotTable.getPivotFields().get("Product").getCalculatedItems();
IPivotItem item = calculatedItems.add("TotalFruit", "=Product[Apple] + Product[Banana]");
get(int index) IPivotItem at the specified index.IPivotItem item by name.intgetCount()IPivotItem objects in the collection.voidforEach, iterator, spliteratorIPivotItem objects in the collection.This value represents the total number of calculated items defined for the associated pivot field. Returns 0 if the collection does not contain any calculated items.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Region", "Amount"},
{"North", 100},
{"South", 200}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B3"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
ICalculatedItems items = pivotTable.getPivotFields().get("Region").getCalculatedItems();
items.add("NorthAndSouth", "=Region[North]+Region[South]");
int count = items.getCount();
IPivotItem objects in the collection.IPivotItem at the specified index.Use this method to retrieve a calculated item from the collection returned by IPivotField.getCalculatedItems().
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Country", "Amount"},
{"France", 100},
{"Germany", 200},
{"Canada", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
pivotTable.getPivotFields().get("Country").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
ICalculatedItems calculatedItems = pivotTable.getPivotFields().get("Country").getCalculatedItems();
calculatedItems.add("Europe", "=France+Germany");
IPivotItem item = calculatedItems.get(0);
index - The zero-based index of the calculated item.IPivotItem at the specified index.IPivotItem item by name.Use this method to retrieve a calculated item from the ICalculatedItems collection of a pivot field.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Status", "Amount"},
{"Pending", 100},
{"Backorder", 200},
{"Shipped", 300}
});
IWorksheet pivotSheet = workbook.getWorksheets().add();
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = pivotSheet.getPivotTables().add(pivotCache, pivotSheet.getRange("A1"));
pivotTable.getPivotFields().get("Status").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
ICalculatedItems calculatedItems = pivotTable.getPivotFields().get("Status").getCalculatedItems();
calculatedItems.add("Open Orders", "=Pending+Backorder");
IPivotItem item = calculatedItems.get("Open Orders");
itemName - The name of the calculated item to retrieve.IPivotItem with the specified name.IPivotItem object.Use the returned item to access the calculated item after it is added to the pivot field's calculated items collection obtained from IPivotField.getCalculatedItems().
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Country", "Amount"},
{"France", 100},
{"Germany", 200},
{"Canada", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
IPivotItem item = pivotTable.getPivotFields().get("Country").getCalculatedItems().add("Europe", "=France+Germany");
name - The name of the calculated item.formula - The formula used to define the calculated item.IPivotItem.This method removes a calculated item from the current ICalculatedItems collection obtained from IPivotField.getCalculatedItems(). Item name matching is case-insensitive. If no calculated item with the specified name exists, this method does nothing.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Status", "Amount"},
{"Pending", 100},
{"Backorder", 200},
{"Shipped", 300}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
pivotTable.getPivotFields().get("Status").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
ICalculatedItems calculatedItems = pivotTable.getPivotFields().get("Status").getCalculatedItems();
calculatedItems.add("Open Orders", "=Pending+Backorder");
calculatedItems.remove("Open Orders");
itemName - The name of the calculated item to remove. If no matching calculated item exists, no item is removed.