Created attachment 23730 [details] Java code Sometime, replaceText() issue exception while delete() and insert() does not. So next code is workaround: try { run.replaceText(oldText, text, 0); } catch (StringIndexOutOfBoundsException e) { //e.printStackTrace(System.err); run.delete(); run.insertBefore(text); } You are can try it on attachment in Bug 47286.
The problem is still reproducible with trunk. Yegor
Fixed in r1143774; shall be part of poi 3.8-beta4