https://bz.apache.org/bugzilla/show_bug.cgi?id=65227
Bug ID: 65227 Summary: possible NPE in org.apache.poi.ss.util.SheetUtil.getCellWidth(cell,def aultCharWidth,formatter,useMergedCells,mergedRegions) Product: POI Version: 5.0.0-FINAL Hardware: PC OS: Linux Status: NEW Severity: major Priority: P2 Component: POI Overall Assignee: dev@poi.apache.org Reporter: blaha.p...@yandex.com Target Milestone: --- Created attachment 37802 --> https://bz.apache.org/bugzilla/attachment.cgi?id=37802&action=edit Pathed SheetUtil.java Our customer reported NPE error when processing excel files and since then we are patching SheetUtil class, for many years. I cannot provide Detailed error log, we cannot test it on production. When going thru code in my opinion NPE can happen in XSSF/SXSSF and i think not in HSSF Workbooks. Would like to upstream this two lines fix so we do not have to keep separate file for this: if (rt != null && rt.getString() != null) { ... } ------Original version---------------- if (cellType == CellType.STRING) { //this line number s 161 in SheetUtil.java RichTextString rt = cell.getRichStringCellValue(); String[] lines = rt.getString().split("\\n"); for (String line : lines) { String txt = line + 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); } --------Patched version--------------------- if (cellType == CellType.STRING) { //this line number s 161 in SheetUtil.java RichTextString rt = cell.getRichStringCellValue(); if (rt != null && rt.getString() != null) { String[] lines = rt.getString().split("\\n"); for (String line : lines) { String txt = line + 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); } } } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org