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
This commit is contained in:
parent
e8234fd032
commit
79250e916f
@ -22,6 +22,7 @@ import static org.apache.poi.POITestCase.testPassesNow;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
@ -739,6 +740,30 @@ public abstract class BaseTestSheetShiftRows {
|
|||||||
|
|
||||||
wb.close();
|
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) {
|
private void createHyperlink(CreationHelper helper, Cell cell, HyperlinkType linkType, String ref) {
|
||||||
cell.setCellValue(ref);
|
cell.setCellValue(ref);
|
||||||
|
Loading…
Reference in New Issue
Block a user