[]
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();
intThe 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();
PivotLineType value that specifies the type of this PivotLine.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();
IPivotCell objects in this pivot line.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();