https://bz.apache.org/bugzilla/show_bug.cgi?id=61840

--- Comment #3 from Javen O'Neal <[email protected]> ---
This works for me in the latest version of POI (and probably also 3.17).
You will get #REF! errors if you shift references above the 1st row in the
workbook, which is the same behavior as Excel.

You are getting #REF! errors likely from one of two scenarios:
1) Formula: "(B1-C1)/B1", shiftRows(x, x, -1)
2) Formula: "(B5-C5)/B5", shiftRows(x, x, -5)

I wrote this unit test to test POI's functionality:
@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 shiftedCell = sheet.getRow(3).getCell(0);
    assertNotNull(shiftedCell);
    assertEquals("(B4-C4)/B4", shiftedCell.getCellFormula());
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to