|Summary:||XWPFRun do not preserve spaces|
|Component:||XWPF||Assignee:||POI Developers List <dev>|
Description Alexey 2010-07-14 15:41:12 UTC
have to fill paragraph with sentence like this: Please call us at 1-800-800-8888 after 8 pm. and I need to make phone number bold Please call us at <b>1-800-800-8888</b> after 8 pm. using this code XWPFRun r = p.createRun(); r.setText("Please call us at"); r = p.createRun(); r.setText("1-800-800-8888"); r.setBold(true); r = p.createRun(); r.setText(" after 8 pm."); as a result I have a document that does not have spaces between runs, like here. Please call us at<b>1-800-800-8888</b>after 8 pm. Please call us at1-800-800-8888after 8 pm. resulting <w:t> node missing attribute xml:space="preserve" I spent several ours trying to find a solution, but do not see it yet.
Comment 1 David Fisher 2010-07-14 16:00:19 UTC
This looks like a duplicate of https://issues.apache.org/bugzilla/show_bug.cgi?id=48070 which should have been in POI 3.6. Are you sure you are using 3.6? Have you tried the 3.7beta1?
Comment 2 Alexey 2010-07-14 16:05:15 UTC
(In reply to comment #1) 48070 is for XSSFCell which is Excel. I am using 3.6-20091214 will try 3.7 beta1
Comment 3 Alexey 2010-07-20 09:29:14 UTC
tried 3.7-beta1-20100620 did not work either.
Comment 4 Yegor Kozlov 2010-07-27 01:40:18 UTC
Should be fixed in r979540 The problem has the same origin as Bug #48070. By default XmlBeans truncates leading and trailing spaces. To preserve them you need to insert the xml:space="preserve" attribute and this is tricky. Regards, Yegor
Comment 5 Alexey 2010-07-27 07:00:22 UTC
Thank you Yegor, it works perfectly.