List of usage examples for org.apache.poi.xssf.usermodel XSSFPivotTable getRowLabelColumns
@Beta
public List<Integer> getRowLabelColumns()
From source file:com.springapp.mvc.CreatePivotTable.java
License:Apache License
public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = (XSSFSheet) wb.createSheet(); XSSFSheet sheet2 = (XSSFSheet) wb.createSheet(); //Create some data to build the pivot table on setCellData(sheet2);/*from w w w. jav a 2 s . com*/ XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference("A1:D5"), new CellReference("A1"), sheet2); //Configure the pivot table //Use first column as row label pivotTable.addRowLabel(0); pivotTable.addRowLabel(3); //pivotTable.addDataColumn(0, false); //pivotTable.addRowLabel(1); //pivotTable.addRowLabel(2); //pivotTable.addRowLabel(3); //pivotTable.addRowLabel(3); //pivotTable.addDataColumn(1, true); //pivotTable.addDataColumn(1, true); //Sum up the second column pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1); //Set the third column as filter //pivotTable.addColumnLabel(DataConsolidateFunction.AVERAGE, 2); //Add filter on forth column //pivotTable.addReportFilter(3); //pivotTable.addReportFilter(0); //pivotTable.addReportFilter(0); //pivotTable.addRowLabel(0); //pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1); System.out.println(pivotTable.getRowLabelColumns()); FileOutputStream fileOut = new FileOutputStream("ooxml-pivottable.xlsx"); wb.write(fileOut); fileOut.close(); }