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 2017/12/01 17:47:29 UTC

svn commit: r1816892 - /poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

Author: onealj
Date: Fri Dec  1 17:47:29 2017
New Revision: 1816892

URL: http://svn.apache.org/viewvc?rev=1816892&view=rev
Log:
bug 61840: add unit test showing that shiftRows does not produce #REF! formula errors if cells are not shifted above the first row

Modified:
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java?rev=1816892&r1=1816891&r2=1816892&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java Fri Dec  1 17:47:29 2017
@@ -22,6 +22,7 @@ import static org.apache.poi.POITestCase
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
@@ -739,6 +740,30 @@ public abstract class BaseTestSheetShift
 
         wb.close();
     }
+    
+    @Test
+    public void test61840_shifting_rows_up_does_not_produce_REF_errors() throws Exception {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet();
+        Cell cell = sheet.createRow(4).createCell(0);
+        
+        cell.setCellFormula("(B5-C5)/B5");
+        sheet.shiftRows(4, 4, -1);
+        
+        // Cell objects created before a row shift are still valid.
+        // The row number of those cell references will be shifted if
+        // the cell is within the shift range.
+        assertEquals("(B4-C4)/B4", cell.getCellFormula());
+        
+        // New cell references are also valid.
+        Cell shiftedCell = sheet.getRow(3).getCell(0);
+        assertNotNull(shiftedCell);
+        assertEquals("(B4-C4)/B4", shiftedCell.getCellFormula());
+    }
+    
+    
+    
+    
 
     private void createHyperlink(CreationHelper helper, Cell cell, HyperlinkType linkType, String ref) {
         cell.setCellValue(ref);



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