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

--- Comment #2 from Worsik <[email protected]> ---
Still valid on 3.11-Final

I think that NPE should be prevented when autosizing column and value should be
treated as empty string.

Code of SheetUtil.java

        if (cellType == Cell.CELL_TYPE_STRING) {
            RichTextString rt = cell.getRichStringCellValue();
!!!         String[] lines = rt.getString().split("\\n");      !!! this is
wrong !!!
            for (int i = 0; i < lines.length; i++) {
                String txt = lines[i] + defaultChar;

                AttributedString str = new AttributedString(txt);
                copyAttributes(font, str, 0, txt.length());

                if (rt.numFormattingRuns() > 0) {
                    // TODO: support rich text fragments
                }

                width = getCellWidth(defaultCharWidth, colspan, style, width,
str);
            }
        }

It could be a benefit if we can set how to treat NULL values when setting Cell
values. For me, it would be better to accept NULL value as empty string (maybe
based on some parameter). When exporting list of objects to Excel via POI, it
is quite annoying to handle all getters like 

        object.getValue() == null ? "" : object.getValue();

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to