List of usage examples for org.apache.poi.ss.usermodel DataConsolidateFunction SUM
DataConsolidateFunction SUM
To view the source code for org.apache.poi.ss.usermodel DataConsolidateFunction SUM.
Click Source Link
From source file:CreatePivotTable.java
License:Apache License
public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet();/* w w w .j a va2 s .c om*/ //Create some data to build the pivot table on setCellData(sheet); XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference("A1:D4"), new CellReference("H5")); //Configure the pivot table //Use first column as row label pivotTable.addRowLabel(0); //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); FileOutputStream fileOut = new FileOutputStream("ooxml-pivottable.xlsx"); wb.write(fileOut); fileOut.close(); wb.close(); }
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 www .j av 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(); }
From source file:packtest.CreatePivotTable.java
License:Apache License
public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet();//from www . j a v a2 s . co m //Create some data to build the pivot table on setCellData(sheet); XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference("A1:D4"), new CellReference("H5")); //Configure the pivot table //Use first column as row label pivotTable.addRowLabel(0); //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); FileOutputStream fileOut = new FileOutputStream(Utils.getPath("ooxml-pivottable.xlsx")); wb.write(fileOut); fileOut.close(); wb.close(); }
From source file:ru.inkontext.poi.CreateCustomPivotTable.java
License:Apache License
public static void main(String[] args) throws IOException, InvalidFormatException { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet();//from w w w. j ava 2s . c o m //Create some data to build the pivot table on setCellData(sheet); new CustomPivotTable(sheet, "A1:D6", "F3").addRowLabel(0) // set first column as 1-th level of rows .excludeSubTotal(0) // excude subtotal .addRowLabel(1) // set second column of source as 2-th level of rows .addColLabel(3).setFormatPivotField(3, 9).addColumnLabel(DataConsolidateFunction.SUM, 2) // Sum up the second column .setFormatDataField(2, 4); //# ##0.00 FileOutputStream fileOut = new FileOutputStream("custom-pivottable.xlsx"); wb.write(fileOut); fileOut.close(); wb.close(); }
From source file:ru.inkontext.poi.CreatePivotTableSimple.java
License:Apache License
public static void main(String[] args) throws IOException, InvalidFormatException { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet();//from w w w. j av a2 s . c o m //Create some data to build the pivot table on setCellData(sheet); XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference("A1:C6", SpreadsheetVersion.EXCEL2007), new CellReference("E3")); pivotTable.addRowLabel(1); // set second column as 1-th level of rows setFormatPivotField(pivotTable, 1, 9); //set format numFmtId=9 0% pivotTable.addRowLabel(0); // set first column as 2-th level of rows pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 2); // Sum up the second column setFormatDataField(pivotTable, 2, 3); //numFmtId=3 # ##0 FileOutputStream fileOut = new FileOutputStream("stackoverflow-pivottable.xlsx"); wb.write(fileOut); fileOut.close(); wb.close(); }