spreadsheet icon indicating copy to clipboard operation
spreadsheet copied to clipboard

Conditional formatting of a cell is not recalculated after deleting its content

Open MTzukanov opened this issue 7 years ago • 2 comments

Other cells are recalculated, but the one that was just deleted is not. Test in "conditional_formatting_cell_is.xlsx".

MTzukanov avatar Jul 10 '17 10:07 MTzukanov

I attach a code snippet here, part of ConditionalFormattingCellValueIsTest class, commented out lines should pass after this ticket is fixed:

    public void B5RedIfNotEqualsToZero_insertDifferentValues_B5FilledCorrectly() {
        spreadsheetPage.setCellValue("B5", "0");
        assertEquals(FALSE_CONDITION_COLOR, spreadsheetPage.getCellColor("B5"));

        spreadsheetPage.setCellValue("B5", "1");
        assertEquals(TRUE_CONDITION_COLOR, spreadsheetPage.getCellColor("B5"));

//        Currently deleting a cell does not affect its own color (bug), although
//        all other cells are updated.
//        Commenting out cell deletion test here and in all other methods until this issue is resolved.
//        https://github.com/vaadin/spreadsheet/issues/577
//        
//        spreadsheetPage.deleteCellValue("B5");
//        assertEquals(FALSE_CONDITION_COLOR, spreadsheetPage.getCellColor("B5"));
    }

    @Test
    public void B6RedIfEqualsToZero_insertValues_B6FilledCorrectly() {
        spreadsheetPage.setCellValue("B6", "0");
        assertEquals(TRUE_CONDITION_COLOR, spreadsheetPage.getCellColor("B6"));

        spreadsheetPage.setCellValue("B6", "1");
        assertEquals(FALSE_CONDITION_COLOR, spreadsheetPage.getCellColor("B6"));

//        spreadsheetPage.deleteCellValue("B6");
//        assertEquals(TRUE_CONDITION_COLOR, spreadsheetPage.getCellColor("B6"));
    }

    @Test
    public void B7RedIfNotEqualsToBooleanFalse_insertValues_B7FilledRed() {
        spreadsheetPage.setCellValue("B7", FALSE_VALUE);
        assertEquals(FALSE_CONDITION_COLOR, spreadsheetPage.getCellColor("B7"));

        spreadsheetPage.setCellValue("B7", TRUE_VALUE);
        assertEquals(TRUE_CONDITION_COLOR, spreadsheetPage.getCellColor("B7"));

//        spreadsheetPage.deleteCellValue("B7");
//        assertEquals(FALSE_CONDITION_COLOR, spreadsheetPage.getCellColor("B7"));
    }

    @Test
    public void B2RedIfEqualsB3_insertValues_B3FilledCorrectly() {
        spreadsheetPage.setCellValue("B2", "1");
        spreadsheetPage.setCellValue("B3", "2");
        assertEquals(FALSE_CONDITION_COLOR, spreadsheetPage.getCellColor("B3"));

//        spreadsheetPage.deleteCellValue("B2");
//        spreadsheetPage.deleteCellValue("B3");
//        assertEquals(TRUE_CONDITION_COLOR, spreadsheetPage.getCellColor("B3"));
    }

MTzukanov avatar Jul 20 '17 06:07 MTzukanov

This is fixed in Pull Request https://github.com/vaadin/spreadsheet/pull/595, which I hope Vaadin will accept eventually. It is waiting on POI 3.17, due out by next week, then all tests will pass. This scenario is one I specifically needed, and found in testing for that PR as well. That code now explicitly adds cells that used to have conditional formatting applied but now do not to the list of cells needing updates transmitted to the client. Currently, as you see, that case is not handled, only cells that currently have conditional formatting are sent, nothing tracks cells that previously had formatting.

WoozyG avatar Aug 31 '17 04:08 WoozyG