diff options
author | Javen O'Neal <onealj@apache.org> | 2017-12-01 17:47:29 +0000 |
---|---|---|
committer | Javen O'Neal <onealj@apache.org> | 2017-12-01 17:47:29 +0000 |
commit | 38becac30c91881b0efb789e13a60855334af945 (patch) | |
tree | 82a68a7b437079ae15b8ef3514b4800d3155703c /src/testcases | |
parent | 0046b3e9a59ba764c38a65b49d239de09318c4b6 (diff) | |
download | poi-38becac30c91881b0efb789e13a60855334af945.tar.gz poi-38becac30c91881b0efb789e13a60855334af945.zip |
bug 61840: add unit test showing that shiftRows does not produce #REF! formula errors if cells are not shifted above the first row
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1816892 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java index ffd86f5f75..6bbfe0a916 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java @@ -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); |