]> source.dussan.org Git - poi.git/commitdiff
bug 61840: add unit test showing that shiftRows does not produce #REF! formula errors...
authorJaven O'Neal <onealj@apache.org>
Fri, 1 Dec 2017 17:47:29 +0000 (17:47 +0000)
committerJaven O'Neal <onealj@apache.org>
Fri, 1 Dec 2017 17:47:29 +0000 (17:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1816892 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

index ffd86f5f75432162e968eee30ac56f8cb6ccddcb..6bbfe0a9168982890f4e6f3200525024ea9364e1 100644 (file)
@@ -22,6 +22,7 @@ import static org.apache.poi.POITestCase.testPassesNow;
 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 BaseTestSheetShiftRows {
 
         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);