poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1760814 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFSheet.java testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
Date Wed, 14 Sep 2016 22:43:08 GMT
Author: onealj
Date: Wed Sep 14 22:43:08 2016
New Revision: 1760814

URL: http://svn.apache.org/viewvc?rev=1760814&view=rev
Log:
sheet names are case insensitive

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

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1760814&r1=1760813&r2=1760814&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Wed Sep 14 22:43:08
2016
@@ -4165,9 +4165,9 @@ public class XSSFSheet extends POIXMLDoc
      * @return The pivot table
      */
     @Beta
-    public XSSFPivotTable createPivotTable(AreaReference source, CellReference position,
Sheet sourceSheet){
-
-        if(source.getFirstCell().getSheetName() != null && !source.getFirstCell().getSheetName().equals(sourceSheet.getSheetName()))
{
+    public XSSFPivotTable createPivotTable(AreaReference source, CellReference position,
Sheet sourceSheet) {
+        final String sourceSheetName = source.getFirstCell().getSheetName();
+        if(sourceSheetName != null && !sourceSheetName.equalsIgnoreCase(sourceSheet.getSheetName()))
{
             throw new IllegalArgumentException("The area is referenced in another sheet than
the "
                     + "defined source sheet " + sourceSheet.getSheetName() + ".");
         }
@@ -4193,8 +4193,10 @@ public class XSSFSheet extends POIXMLDoc
      */
     @Beta
     public XSSFPivotTable createPivotTable(AreaReference source, CellReference position){
-        if(source.getFirstCell().getSheetName() != null && !source.getFirstCell().getSheetName().equals(this.getSheetName()))
{
-            return createPivotTable(source, position, getWorkbook().getSheet(source.getFirstCell().getSheetName()));
+        final String sourceSheetName = source.getFirstCell().getSheetName();
+        if(sourceSheetName != null && !sourceSheetName.equalsIgnoreCase(this.getSheetName()))
{
+            final XSSFSheet sourceSheet = getWorkbook().getSheet(sourceSheetName);
+            return createPivotTable(source, position, sourceSheet);
         }
         return createPivotTable(source, position, this);
     }

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=1760814&r1=1760813&r2=1760814&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 Wed
Sep 14 22:43:08 2016
@@ -17,11 +17,11 @@
 package org.apache.poi.xssf.usermodel;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
 
-import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DataConsolidateFunction;
@@ -350,4 +350,21 @@ public class TestXSSFPivotTable {
         
         offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0);
     }
+    
+    @Test
+    public void testPivotTableSheetNamesAreCaseInsensitive() {
+        wb.setSheetName(0,  "original");
+        wb.setSheetName(1,  "offset");
+        XSSFSheet original = wb.getSheet("OriginaL");
+        XSSFSheet offset = wb.getSheet("OffseT");
+        // assume sheets are accessible via case-insensitive name
+        assertNotNull(original);
+        assertNotNull(offset);
+        
+        AreaReference source = new AreaReference("ORIGinal!A1:C2", _testDataProvider.getSpreadsheetVersion());
+        // create a pivot table on the same sheet, case insensitive
+        original.createPivotTable(source, new CellReference("W1"));
+        // create a pivot table on a different sheet, case insensitive
+        offset.createPivotTable(source, new CellReference("W1"));
+    }
 }



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


Mime
View raw message