The CELL_TYPE_NUMERIC doesn't produce the numeric cell type and rather creates a cell with blank CellType. Every other CellType : CELL_TYPE_BLANK CELL_TYPE_STRING CELL_TYPE_FORMULA CELL_TYPE_ERROR CELL_TYPE_BOOLEAN is working properly. The Output of the code: NUMERIC BLANK NUMERIC BLANK NUMERIC BLANK STRING STRING FORMULA FORMULA STRING STRING BLANK BLANK NUMERIC BLANK BOOLEAN BOOLEAN
Created attachment 34900 [details] The java code which collects celltype from a cell and writes it to another cell. But the celltype NUMERIC is inherited as blank.
Created attachment 34901 [details] The test xlsx file
*** Bug 60958 has been marked as a duplicate of this bug. ***
What happens when you copy the cell value rather than copying the cell type without the value?
This is kind of "on purpose" right now: private CellType XSSFCell.getBaseCellType(boolean blankCells) { switch (_cell.getT().intValue()) { case STCellType.INT_N: if (!_cell.isSetV() && blankCells) { // ooxml does have a separate cell type of 'blank'. A blank cell gets encoded as // (either not present or) a numeric cell with no value set. // The formula evaluator (and perhaps other clients of this interface) needs to // distinguish blank values which sometimes get translated into zero and sometimes // empty string, depending on context return CellType.BLANK; } return CellType.NUMERIC; So a workaround is to set a value of "0" via if(addd == CellType.NUMERIC) { cell2.setCellValue(0.0); } A potential "fix" would be to set a zero-value at XSSFCell.setCellType(): if(!_cell.isSetV()) { _cell.setV("0.0"); } However there are likely some side-effects of doing so...