poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1647088 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
Date Sun, 21 Dec 2014 06:20:07 GMT
Author: nick
Date: Sun Dec 21 06:20:06 2014
New Revision: 1647088

URL: http://svn.apache.org/r1647088
Log:
Patch from  Kamil Linek from bug #57071 - 3+ XSSF column label names for pivot tables

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java?rev=1647088&r1=1647087&r2=1647088&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java Sun Dec 21
06:20:06 2014
@@ -296,8 +296,8 @@ public class XSSFPivotTable extends POIX
         addDataColumn(columnIndex, true);
         addDataField(function, columnIndex, valueFieldName);
 
-        //Only add colfield if there is already one.
-        if (pivotTableDefinition.getDataFields().getCount() > 1) {
+        // colfield should be added for the second one.
+        if (pivotTableDefinition.getDataFields().getCount() == 2) {
             CTColFields colFields;
             if(pivotTableDefinition.getColFields() != null) {
                 colFields = pivotTableDefinition.getColFields();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java?rev=1647088&r1=1647087&r2=1647088&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java Sun
Dec 21 06:20:06 2014
@@ -46,6 +46,8 @@ public class TestXSSFPivotTable extends
         cell2.setCellValue("#");
         Cell cell7 = row1.createCell(2);
         cell7.setCellValue("Data");
+        Cell cell10 = row1.createCell(3);
+        cell10.setCellValue("Value");
 
         Row row2 = sheet.createRow(1);
         Cell cell3 = row2.createCell(0);
@@ -54,6 +56,8 @@ public class TestXSSFPivotTable extends
         cell4.setCellValue(10);
         Cell cell8 = row2.createCell(2);
         cell8.setCellValue("Apa");
+        Cell cell11 = row1.createCell(3);
+        cell11.setCellValue(11.11);
 
         Row row3 = sheet.createRow(2);
         Cell cell5 = row3.createCell(0);
@@ -62,8 +66,10 @@ public class TestXSSFPivotTable extends
         cell6.setCellValue(9);
         Cell cell9 = row3.createCell(2);
         cell9.setCellValue("Bepa");
+        Cell cell12 = row1.createCell(3);
+        cell12.setCellValue(12.12);
 
-        AreaReference source = new AreaReference("A1:B2");
+        AreaReference source = new AreaReference("A1:C2");
         pivotTable = sheet.createPivotTable(source, new CellReference("H5"));
     }
 
@@ -117,6 +123,39 @@ public class TestXSSFPivotTable extends
     }
 
     /**
+     * Verify that it's possible to create three column labels with different DataConsolidateFunction
+     */
+    public void testAddThreeDifferentColumnLabelsToPivotTable() {
+        int columnOne = 0;
+        int columnTwo = 1;
+        int columnThree = 2;
+
+        pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnOne);
+        pivotTable.addColumnLabel(DataConsolidateFunction.MAX, columnTwo);
+        pivotTable.addColumnLabel(DataConsolidateFunction.MIN, columnThree);
+        CTPivotTableDefinition defintion = pivotTable.getCTPivotTableDefinition();
+
+        assertEquals(defintion.getDataFields().getDataFieldList().size(), 3);
+    }
+    
+    
+    /**
+     * Verify that it's possible to create three column labels with the same DataConsolidateFunction
+     */
+    public void testAddThreeSametColumnLabelsToPivotTable() {
+        int columnOne = 0;
+        int columnTwo = 1;
+        int columnThree = 2;
+
+        pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnOne);
+        pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnTwo);
+        pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnThree);
+        CTPivotTableDefinition defintion = pivotTable.getCTPivotTableDefinition();
+
+        assertEquals(defintion.getDataFields().getDataFieldList().size(), 3);
+    }
+    
+    /**
      * Verify that when creating two column labels, a col field is being created and X is
set to -2.
      */
     public void testAddTwoColumnLabelsToPivotTable() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message