You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/06/04 16:40:01 UTC

svn commit: r951420 - in /poi/trunk: src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/FormulaRefs.xls

Author: nick
Date: Fri Jun  4 14:40:01 2010
New Revision: 951420

URL: http://svn.apache.org/viewvc?rev=951420&view=rev
Log:
Add unit test for bug #45970 - shows that we can read Formulas with URL based references in them, but we can't change them properly. Part of the unit test is disabled for now

Added:
    poi/trunk/test-data/spreadsheet/FormulaRefs.xls   (with props)
Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=951420&r1=951419&r2=951420&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Fri Jun  4 14:40:01 2010
@@ -1588,4 +1588,87 @@ public final class TestBugs extends Base
        wb = writeOutAndReadBack(wb);
        assertEquals(2, wb.getNumberOfSheets());
     }
+    
+    /**
+     * Problems with formula references to 
+     *  sheets via URLs
+     */
+    public void test45970() throws Exception {
+       HSSFWorkbook wb = openSample("FormulaRefs.xls");
+       assertEquals(3, wb.getNumberOfSheets());
+       
+       HSSFSheet s = wb.getSheetAt(0);
+       HSSFRow row;
+       
+       row = s.getRow(0);
+       assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(1);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("B1", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(2);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(3);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(4);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("'[\u0005$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       // Change 4
+       row.getCell(1).setCellFormula("'[\u0005$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2");
+       row.getCell(1).setCellValue(123.0);
+       
+       // Add 5
+       row = s.createRow(5);
+       row.createCell(1, Cell.CELL_TYPE_FORMULA);
+       row.getCell(1).setCellFormula("'[\u0005$http://example.com/FormulaRefs.xls]Sheet1'!B1");
+       row.getCell(1).setCellValue(234.0);
+       
+       
+       // Re-test
+       wb = writeOutAndReadBack(wb);
+       s = wb.getSheetAt(0);
+       
+       row = s.getRow(0);
+       assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(1);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("B1", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(2);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(3);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
+       assertEquals(112.0, row.getCell(1).getNumericCellValue());
+       
+// TODO - Fix these so they work...
+if(1==2) {
+       row = s.getRow(4);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("'[\u0005$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
+       assertEquals(123.0, row.getCell(1).getNumericCellValue());
+       
+       row = s.getRow(5);
+       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals("'[\u0005$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
+       assertEquals(234.0, row.getCell(1).getNumericCellValue());
+}
+    }
 }

Added: poi/trunk/test-data/spreadsheet/FormulaRefs.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/FormulaRefs.xls?rev=951420&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/FormulaRefs.xls
------------------------------------------------------------------------------
    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