[]
        
(Showing Draft Content)

IPivotItemList

Interface IPivotItemList

All Superinterfaces:
Iterable<IPivotItem>

public interface IPivotItemList extends Iterable<IPivotItem>
Represents a collection of 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();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int field)
    Gets the pivot item at the specified index in this list.
    int
    Gets the number of pivot items in this list.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • getCount

      int getCount()
      Gets the number of pivot items in this list.

      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();
       
      Returns:
      The number of objects in the collection.
    • get

      IPivotItem get(int field)
      Gets the pivot item at the specified index in this list.
      
       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);
       
      Parameters:
      field - The zero-based index in the pivot item list.
      Returns:
      The pivot item at the specified index.