Cell borders not updated correctly when removing border
I'm creating a UI that lets users add/remove borders from selected spreadsheet cells.
It appears that the top and left borders are rendered as part of the cell above/to the left of the cell with the border. As such, when you remove the border from a cell, the spreadsheet component is not updated correctly.
See the sample code for example. When you select a cell, click the "Border on" button, then the "Border off" button, the top and left border components are not removed:

I've done further testing (not included in the attached project) that shows that the border is correctly removed from the underlying workbook.
The work-around is to, for every cell you update, add the cell above and the cell to the left to the list of cells to refresh. The order in which you refresh cells affects which borders are shown - you need to refresh from top to bottom and left to right. Unfortunately there's no "refreshAllCells()" method.
Example code: spreadsheet-border.zip
For the work-around, use the following updated setBorder(BorderStyle method:
private void setBorder(BorderStyle borderStyle) {
List<Cell> cellsToRefresh = new LinkedList<>();
spreadsheet.getSelectedCellReferences().forEach(cellReference -> {
Cell cell = getOrCreateCell(cellReference);
XSSFCellStyle style = cloneStyle(cell);
style.setBorderTop(borderStyle);
style.setBorderBottom(borderStyle);
style.setBorderLeft(borderStyle);
style.setBorderRight(borderStyle);
cell.setCellStyle(style);
if (cell.getRowIndex() > 0) {
cellsToRefresh.add(getOrCreateCell(new CellReference(cell.getRowIndex() - 1, cell.getColumnIndex())));
}
if (cell.getColumnIndex() > 0) {
cellsToRefresh.add(getOrCreateCell(new CellReference(cell.getRowIndex(), cell.getColumnIndex() - 1)));
}
cellsToRefresh.add(cell);
});
spreadsheet.refreshCells(cellsToRefresh);
}