Bug 49941 - Applying Font to XSSFRichTextString looses non leading/trailing spaces.
Summary: Applying Font to XSSFRichTextString looses non leading/trailing spaces.
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-16 10:55 UTC by stich23
Modified: 2010-09-16 12:01 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stich23 2010-09-16 10:55:23 UTC
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.
Comment 1 Nick Burch 2010-09-16 12:01:24 UTC
Fixed, along with unit test, in r997811.