poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1078065 - in /poi/trunk: src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java test-data/spreadsheet/50867_with_table.xlsx
Date Fri, 04 Mar 2011 17:31:52 GMT
Author: nick
Date: Fri Mar  4 17:31:52 2011
New Revision: 1078065

URL: http://svn.apache.org/viewvc?rev=1078065&view=rev
Log:
Add unit test showing that bug #50867 works fine

Added:
    poi/trunk/test-data/spreadsheet/50867_with_table.xlsx   (with props)
Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1078065&r1=1078064&r2=1078065&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Fri Mar
 4 17:31:52 2011
@@ -42,6 +42,7 @@ import org.apache.poi.ss.usermodel.Workb
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.model.CalculationChain;
+import org.apache.poi.xssf.model.Table;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
 
@@ -821,4 +822,60 @@ public final class TestXSSFBugs extends 
        cell = row.getCell(2);
        assertEquals(text, cell.getStringCellValue());
     }
+    
+    /**
+     * Adding sheets when one has a table, then re-ordering
+     */
+    public void test50867() throws Exception {
+       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50867_with_table.xlsx");
+       assertEquals(3, wb.getNumberOfSheets());
+       
+       XSSFSheet s1 = wb.getSheetAt(0);
+       XSSFSheet s2 = wb.getSheetAt(1);
+       XSSFSheet s3 = wb.getSheetAt(2);
+       assertEquals(1, s1.getTables().size());
+       assertEquals(0, s2.getTables().size());
+       assertEquals(0, s3.getTables().size());
+       
+       Table t = s1.getTables().get(0);
+       assertEquals("Tabella1", t.getName());
+       assertEquals("Tabella1", t.getDisplayName());
+       assertEquals("A1:C3", t.getCTTable().getRef());
+       
+       // Add a sheet and re-order
+       XSSFSheet s4 = wb.createSheet("NewSheet");
+       wb.setSheetOrder(s4.getSheetName(), 0);
+       
+       // Check on tables
+       assertEquals(1, s1.getTables().size());
+       assertEquals(0, s2.getTables().size());
+       assertEquals(0, s3.getTables().size());
+       assertEquals(0, s4.getTables().size());
+       
+       // Refetch to get the new order
+       s1 = wb.getSheetAt(0);
+       s2 = wb.getSheetAt(1);
+       s3 = wb.getSheetAt(2);
+       s4 = wb.getSheetAt(3);
+       assertEquals(0, s1.getTables().size());
+       assertEquals(1, s2.getTables().size());
+       assertEquals(0, s3.getTables().size());
+       assertEquals(0, s4.getTables().size());
+       
+       // Save and re-load
+       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+       s1 = wb.getSheetAt(0);
+       s2 = wb.getSheetAt(1);
+       s3 = wb.getSheetAt(2);
+       s4 = wb.getSheetAt(3);
+       assertEquals(0, s1.getTables().size());
+       assertEquals(1, s2.getTables().size());
+       assertEquals(0, s3.getTables().size());
+       assertEquals(0, s4.getTables().size());
+       
+       t = s2.getTables().get(0);
+       assertEquals("Tabella1", t.getName());
+       assertEquals("Tabella1", t.getDisplayName());
+       assertEquals("A1:C3", t.getCTTable().getRef());
+    }
 }

Added: poi/trunk/test-data/spreadsheet/50867_with_table.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/50867_with_table.xlsx?rev=1078065&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/50867_with_table.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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


Mime
View raw message