[]
        
(Showing Draft Content)

IPivotLine

Interface IPivotLine


public interface IPivotLine
Represents a line of rows or columns in a PivotTable.

An IPivotLine belongs to a row or column axis and groups the IPivotCell objects that make up a single logical line in the PivotTable. Use this interface to inspect the line type, access the cells in the line, and determine the line position within the axis.


 Object[][] sourceData = {
     {"Category", "Product", "Amount"},
     {"Fruit", "Apple", 100},
     {"Fruit", "Pear", 80},
     {"Drink", "Tea", 60}
 };
 worksheet.getRange("G1:I4").setValue(sourceData);
 IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("G1:I4"));
 IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("A1"), "Sales");
 pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
 pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
 IPivotLine pivotLine = pivotTable.getPivotRowAxis().getPivotLines().get(0);
 PivotLineType lineType = pivotLine.getLineType();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the type of this PivotLine.
    Gets the collection of pivot cells in this pivot line.
    int
    Gets the position of this PivotLine in its parent PivotLines collection.
  • Method Details

    • getLineType

      PivotLineType getLineType()
      Gets the type of this PivotLine.

      The returned PivotLineType indicates whether the line is a regular line, a subtotal line, a grand total line, or a blank line in the PivotTable axis.

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Fruit", "Apple", 100},
           {"Fruit", "Pear", 80},
           {"Drink", "Tea", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "Sales");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IPivotLine pivotLine = pivotTable.getPivotRowAxis().getPivotLines().get(0);
       PivotLineType lineType = pivotLine.getLineType();
       
      Returns:
      A PivotLineType value that specifies the type of this PivotLine.
    • getPivotLineCells

      IPivotLineCells getPivotLineCells()
      Gets the collection of pivot cells in this pivot line.

      Use this method to access the IPivotCell objects that belong to the current row or column line in a PivotTable axis.

      
       Object[][] sourceData = new Object[][] {
           {"Product", "Category", "Amount"},
           {"Example Speaker", "Consumer Electronics", 4270},
           {"Example Mobile", "Mobile", 9062}
       };
       worksheet.getRange("G1:I3").setValue(sourceData);
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("G1:I3"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("A1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IPivotLine pivotLine = pivotTable.getPivotRowAxis().getPivotLines().get(0);
       IPivotLineCells pivotLineCells = pivotLine.getPivotLineCells();
       
      Returns:
      The collection of IPivotCell objects in this pivot line.
    • getPosition

      int getPosition()
      Gets the position of this PivotLine in its parent PivotLines collection.

      The returned value is the zero-based index of the PivotLine within the row or column axis that contains it.

      
       Object[][] sourceData = {
           {"Category", "Product", "Amount"},
           {"Fruit", "Apple", 100},
           {"Fruit", "Pear", 80},
           {"Drink", "Tea", 60}
       };
       worksheet.getRange("G1:I4").setValue(sourceData);
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("G1:I4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("A1"), "Sales");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IPivotLine pivotLine = pivotTable.getPivotRowAxis().getPivotLines().get(0);
       int position = pivotLine.getPosition();
       
      Returns:
      The zero-based position of the PivotLine in its parent collection.