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); }
We are not going to just copy NPOI. Please provide real world examples. POI is a volunteer project and it is normally best to provide a patch with a test case yourself.