https://bz.apache.org/bugzilla/show_bug.cgi?id=68232
Bug ID: 68232 Summary: formatValue(StringBuffer,Object)@CellTextFormatter can have an index out of range issue Product: POI Version: 5.3.x-dev Hardware: PC Status: NEW Severity: normal Priority: P2 Component: SS Common Assignee: dev@poi.apache.org Reporter: zhong...@pku.org.cn Target Milestone: --- The code is as follows: public void formatValue(StringBuffer toAppendTo, Object obj) { int start = toAppendTo.length(); String text = obj.toString(); if (obj instanceof Boolean) { text = text.toUpperCase(Locale.ROOT); } toAppendTo.append(desc); for (int textPo : textPos) { int pos = start + textPo; toAppendTo.replace(pos, pos + 1, text); } } NPOI fixed a bug: https://github.com/nissl-lab/npoi/commit/c546978db6bb703464ec9c58e8697b3f91709a86 The buggy code of NPOI is as follows: public override void FormatValue(StringBuilder toAppendTo, Object obj){... for (int i = 0; i < textPos.Length; i++) { int pos = start + textPos[i]; //toAppendTo.Replace(pos, pos + 1, text); toAppendTo.Remove(pos, 1).Insert(pos, text); } } The fixed code is as follows: public override void FormatValue(StringBuilder toAppendTo, Object obj){... toAppendTo.Replace("\0", text); } -- 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