If a create an XSSFRichTextString as follows: RichTextString text = workbook.getCreationHelper().createRichTextString( "Test String" ) ; and apply formatting to the first 4 characters "Test": text.applyFont( 0 , 4 , FONT ) ; then the remaning text " String" loses its leading white space when rendered in Excel. the generated Open XML sharedStrings.xml contains the following: - <si> - <r> - <rPr> <u val="single" /> <sz val="11.0" /> <rFont val="Calibri" /> </rPr> <t>Test</t> </r> - <r> <t> String</t> </r> </si> The leading space is present but the XML space preserving attribute needs to be set as follows: - <si> - <r> - <rPr> <u val="single" /> <sz val="11.0" /> <rFont val="Calibri" /> </rPr> <t>Test</t> </r> - <r> <t xml:space="preserve"> String</t> </r> </si> This is not currently possible that I can see in the POI libraries unless I am missing something? If no formatting is applied to the XSSFRichTextString then the XML preserve space attribute is set but when being split for formatting it does not seem to be accessible.
Fixed, along with unit test, in r997811.