[]
Iterable<IPivotItem>IPivotItem objects in a PivotTable field.This interface provides access to the PivotTable items that belong to a field. Each item represents a distinct entry in the field and can be enumerated by using the inherited Iterable support. This interface is typically obtained from IPivotField.getPivotItems().
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Category", "Product", "Amount"},
{"Fruit", "Apple", 100},
{"Fruit", "Orange", 200},
{"Vegetable", "Carrot", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "pivotTable1");
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
IPivotValueCell valueCell = pivotTable.pivotValueCell(0, 0);
IPivotCell pivotCell = valueCell.getPivotCell();
IPivotItemList rowItems = pivotCell.getRowItems();
This method returns the number of IPivotItem objects contained in the current IPivotItemList.
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Category", "Product", "Amount"},
{"Fruit", "Apple", 100},
{"Fruit", "Orange", 200},
{"Vegetable", "Carrot", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "pivotTable1");
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
IPivotValueCell valueCell = pivotTable.pivotValueCell(0, 0);
IPivotCell pivotCell = valueCell.getPivotCell();
IPivotItemList rowItems = pivotCell.getRowItems();
int count = rowItems.getCount();
worksheet.getRange("G1:J4").setValue(new Object[][] {
{"Category", "Product", "Amount", "Country"},
{"Fruit", "Apple", 100, "USA"},
{"Fruit", "Orange", 200, "USA"},
{"Vegetable", "Carrot", 150, "Canada"}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("G1:J4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("A1"), "pivotTable1");
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
IPivotValueCell valueCell = pivotTable.pivotValueCell(0, 0);
IPivotCell pivotCell = valueCell.getPivotCell();
IPivotItemList rowItems = pivotCell.getRowItems();
IPivotItem item = rowItems.get(0);
field - The zero-based index in the pivot item list.