You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/11 00:11:42 UTC

svn commit: r1747819 - /poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java

Author: onealj
Date: Sat Jun 11 00:11:41 2016
New Revision: 1747819

URL: http://svn.apache.org/viewvc?rev=1747819&view=rev
Log:
bug 57840: add test using a Data Table not anchored at A1

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

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=1747819&r1=1747818&r2=1747819&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 Sat Jun 11 00:11:41 2016
@@ -117,13 +117,11 @@ public final class TestXSSFTable {
     @Test
     public void findColumnIndex() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx");
-        // FIXME: use a worksheet where upper left cell of table is not A1 so that we test
-        // that XSSFTable.findColumnIndex returns the column index relative to the first
-        // column in the table, not the column number in the sheet
 
         XSSFTable table = wb.getTable("\\_Prime.1");
         assertNotNull(table);
-        assertEquals(0, table.findColumnIndex("calc='#*'#"));
+        assertEquals("column header has special escaped characters",
+                0, table.findColumnIndex("calc='#*'#"));
         assertEquals(1, table.findColumnIndex("Name"));
         assertEquals(2, table.findColumnIndex("Number"));
 
@@ -136,6 +134,21 @@ public final class TestXSSFTable {
 
         wb.close();
     }
+
+    @Test
+    public void findColumnIndexIsRelativeToTableNotSheet() throws IOException {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("DataTableCities.xlsx");
+        XSSFTable table = wb.getTable("SmallCity");
+
+        // Make sure that XSSFTable.findColumnIndex returns the column index relative to the first
+        // column in the table, not the column number in the sheet
+        assertEquals(0, table.findColumnIndex("City")); // column I in worksheet but 0th column in table
+        assertEquals(1, table.findColumnIndex("Latitude"));
+        assertEquals(2, table.findColumnIndex("Longitude"));
+        assertEquals(3, table.findColumnIndex("Population"));
+
+        wb.close();
+    }
 
     @Test
     public void getSheetName() throws IOException {



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