You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2017/05/29 19:51:42 UTC

[Bug 60959] Setting the cell to type numeric results in cell type blank

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

--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
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...

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org