poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1747771 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFTable.java testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
Date Fri, 10 Jun 2016 18:45:14 GMT
Author: onealj
Date: Fri Jun 10 18:45:14 2016
New Revision: 1747771

URL: http://svn.apache.org/viewvc?rev=1747771&view=rev
Log:
bug 57840: add unit tests for XSSFTable methods; rename XSSFTable.getNumerOfMappedColumns()
to getNumberOfMappedColumn()

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java?rev=1747771&r1=1747770&r2=1747771&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java Fri Jun 10 18:45:14
2016
@@ -243,15 +243,25 @@ public class XSSFTable extends POIXMLDoc
     /**
      * @return  the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)
      */
-    public long getNumerOfMappedColumns() {
+    public long getNumberOfMappedColumns() {
         return ctTable.getTableColumns().getCount();
     }
+
+    /**
+     * @return  the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)
+     * @deprecated 3.15 beta 2. Use {@link #getNumberOfMappedColumns}.
+     */
+    public long getNumerOfMappedColumns() {
+        return getNumberOfMappedColumns();
+    }
+
     
     
     /**
      * @return The reference for the cell in the top-left part of the table
      * (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref) 
      *
+     * Does not track updates to underlying changes to CTTable
      */
     public CellReference getStartCellReference() {
         if (startCellReference==null) {
@@ -269,6 +279,7 @@ public class XSSFTable extends POIXMLDoc
      * @return The reference for the cell in the bottom-right part of the table
      * (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref)
      *
+     * Does not track updates to underlying changes to CTTable
      */
     public CellReference getEndCellReference() {
         if (endCellReference==null) {
@@ -284,6 +295,7 @@ public class XSSFTable extends POIXMLDoc
     /**
      *  @return the total number of rows in the selection. (Note: in this version autofiltering
is ignored)
      *
+     * Does not track updates to underlying changes to CTTable
      */
     public int getRowCount() {
         CellReference from = getStartCellReference();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1747771&r1=1747770&r2=1747771&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Fri Jun
10 18:45:14 2016
@@ -1273,7 +1273,7 @@ public final class TestXSSFSheet extends
         for(XSSFTable table : tables) {
             System.out.println("XPath: " + table.getCommonXpath());
             System.out.println("Name: " + table.getName());
-            System.out.println("Mapped Cols: " + table.getNumerOfMappedColumns());
+            System.out.println("Mapped Cols: " + table.getNumberOfMappedColumns());
             System.out.println("Rowcount: " + table.getRowCount());
             System.out.println("End Cell: " + table.getEndCellReference());
             System.out.println("Start Cell: " + table.getStartCellReference());

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java?rev=1747771&r1=1747770&r2=1747771&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java Fri Jun
10 18:45:14 2016
@@ -18,7 +18,9 @@
 package org.apache.poi.xssf.usermodel;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -29,6 +31,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.util.TempFile;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@@ -134,4 +137,92 @@ public final class TestXSSFTable {
         wb.close();
     }
 
+    @Test
+    public void getSheetName() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals("Table", table.getSheetName());
+        wb.close(); 
+    }
+
+    @Test
+    public void isHasTotalsRow() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertFalse(table.isHasTotalsRow());
+        wb.close(); 
+    }
+
+    @Test
+    public void getStartColIndex() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(0, table.getStartColIndex());
+        wb.close(); 
+    }
+
+    @Test
+    public void getEndColIndex() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(2, table.getEndColIndex());
+        wb.close(); 
+    }
+
+    @Test
+    public void getStartRowIndex() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(0, table.getStartRowIndex());
+        wb.close(); 
+    }
+
+    @Test
+    public void getEndRowIndex() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(6, table.getEndRowIndex());
+        wb.close(); 
+    }
+
+    @Test
+    public void getStartCellReference() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(new CellReference("A1"), table.getStartCellReference());
+        wb.close(); 
+    }
+
+    @Test
+    public void getEndCellReference() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(new CellReference("C7"), table.getEndCellReference());
+        wb.close(); 
+    }
+
+    @Test
+    public void getNumberOfMappedColumns() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals(3, table.getNumberOfMappedColumns());
+        wb.close(); 
+    }
+
+    @Test
+    public void getAndSetDisplayName() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
+        XSSFTable table = wb.getTable("\\_Prime.1");
+        assertEquals("\\_Prime.1", table.getDisplayName());
+
+        table.setDisplayName(null);
+        assertNull(table.getDisplayName());
+        assertEquals("\\_Prime.1", table.getName()); // name and display name are different
+
+        table.setDisplayName("Display name");
+        assertEquals("Display name", table.getDisplayName());
+        assertEquals("\\_Prime.1", table.getName()); // name and display name are different
+
+        wb.close();
+    }
 }



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


Mime
View raw message