spreadsheet icon indicating copy to clipboard operation
spreadsheet copied to clipboard

Twice dragging a formula of a formatted cell displaying ###

Open vaadin-bot opened this issue 8 years ago • 2 comments

Originally by dattukv


1] Create a row with data format $0.00 on the cells like below

    Spreadsheet spreadsheet = new Spreadsheet();
    Row row = spreadsheet.getActiveSheet().createRow(0);
    for (int i = 0; i < 20; i++) {
        Cell cell = row.createCell(i);
        SpreadsheetUtil.applyDataFormatOnCell("$0.00", cell, spreadsheet);
    }

2]Now when spreadsheet is displayed, enter a 6 digit number (like 333333) in Cell A1. Now Copy this cell value to other cells by dragging the cell. Value will be copied to other cells. Do the dragging again on the same cells. When you drag second time cells are displaying ### instead of values


Imported from https://dev.vaadin.com/ issue #20249

vaadin-bot avatar Sep 07 '16 09:09 vaadin-bot

Originally by dattukv


Sorry missed the content of SpreadsheetUtil.applyDataFormatOnCell(). Pasting here

public static void applyDataFormatOnCell(String format, Cell cell, Spreadsheet spreadsheet) { XSSFCellStyle style = (XSSFCellStyle) cloneStyle(cell, spreadsheet); Short dataFormat = spreadsheet.getWorkbook().createDataFormat().getFormat(format); style.setDataFormat(dataFormat); cell.setCellStyle(style); }

public static CellStyle cloneStyle(Cell cell, final Spreadsheet spreadsheet) {
    CellStyle newStyle = spreadsheet.getWorkbook().createCellStyle();
    newStyle.cloneStyleFrom(cell.getCellStyle());
    return newStyle;
}

vaadin-bot avatar Sep 07 '16 09:09 vaadin-bot

If the result of the second drag is that cell values are replaced with formulas, and the text is expected to overflow into adjacent empty cells when displayed, the bug here could actually be the one from

https://github.com/vaadin/spreadsheet/issues/456

WoozyG avatar Jan 23 '17 20:01 WoozyG