[]
        
(Showing Draft Content)

IPivotLines

Interface IPivotLines

All Superinterfaces:
Iterable<IPivotLine>

public interface IPivotLines extends Iterable<IPivotLine>
Represents a collection of lines on the row or column axis of a PivotTable report.

Each IPivotLine in this collection corresponds to a row or column line in the PivotTable report and contains a set of PivotCells. Use this interface to access the lines returned by IPivotAxis.getPivotLines() and to enumerate or retrieve individual pivot lines by position.


 worksheet.getRange("A1:C5").setValue(new Object[][] {
     {"Category", "Product", "Amount"},
     {"Fruit", "Apple", 100},
     {"Fruit", "Orange", 200},
     {"Drink", "Tea", 150},
     {"Drink", "Coffee", 120}
 });
 IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
 IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
 pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
 pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
 IPivotLines pivotLines = pivotTable.getPivotRowAxis().getPivotLines();
 IPivotLine firstLine = pivotLines.get(0);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int index)
    Gets the IPivotLine at the specified position in this collection.
    int
    Gets the number of items in the PivotLines collection.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • getCount

      int getCount()
      Gets the number of items in the PivotLines collection.

      This collection contains the row or column pivot lines associated with a pivot axis, such as the collection returned by IPivotAxis.getPivotLines().

      
       Object[][] sourceData = new Object[][] {
           {"Product", "Category", "Amount"},
           {"Apple", "Fruit", 100},
           {"Pear", "Fruit", 80},
           {"Desk", "Office", 120}
       };
       worksheet.getRange("A1:C4").setValue(sourceData);
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       int count = pivotTable.getPivotRowAxis().getPivotLines().getCount();
       
      Returns:
      The number of items in the PivotLines collection.
    • get

      IPivotLine get(int index)
      Gets the IPivotLine at the specified position in this collection.

      Use this method to retrieve a row-axis or column-axis pivot line by its zero-based index from the collection returned by IPivotAxis.getPivotLines().

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Fruit", "Apple", 100},
           {"Fruit", "Orange", 200},
           {"Drink", "Tea", 150},
           {"Drink", "Coffee", 120}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IPivotLine pivotLine = pivotTable.getPivotRowAxis().getPivotLines().get(0);
       
      Parameters:
      index - The zero-based position of the pivot line in this collection.
      Returns:
      The IPivotLine at the specified position.