You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Dale Monti <dm...@linoma.com> on 2009/10/23 21:17:55 UTC

Preserving leading and trailing spaces XSSFCell

I would like to have a string value in a cell that maintains the leading 
and trailing spaces. If I set a String value in a cell with leading and 
trailing spaces, the value seems to be preserved in the XML, but does 
not display in Excel.
For example:
XSSFCell cell = row.createCell(0);
cell.setCellValue("   XYZ   ");

Yeilds <si><t>   XYZ   </t></si> in sharedStrings.xml but does not 
display the spaces in Excel.

If you just type the value in Excel you get
<si><t xml:space="preserve">    XYZ    </t></si>

How can I preserve these spaces using POI?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Preserving leading and trailing spaces XSSFCell

Posted by Yegor Kozlov <ye...@dinom.ru>.
I confirmed the behavior and it looks like a bug to me. If a string has leading or trailing spaces then the 
xml:space="preserve" attribute must be set, otherwise the string is trimmed in Excel.

Can you file a bug in Bugzilla so that this request is not forgotten?

Yegor

> Well... No one has responded to my post. Which usually means it cannot 
> be done, or there is some incredibly obvious thing I am missing. If 
> someone could verify which is the case I would appreciate it.
> 
> Thanks
> 
> Dale Monti wrote:
>> I would like to have a string value in a cell that maintains the 
>> leading and trailing spaces. If I set a String value in a cell with 
>> leading and trailing spaces, the value seems to be preserved in the 
>> XML, but does not display in Excel.
>> For example:
>> XSSFCell cell = row.createCell(0);
>> cell.setCellValue("   XYZ   ");
>>
>> Yeilds <si><t>   XYZ   </t></si> in sharedStrings.xml but does not 
>> display the spaces in Excel.
>>
>> If you just type the value in Excel you get
>> <si><t xml:space="preserve">    XYZ    </t></si>
>>
>> How can I preserve these spaces using POI?
>>
>> Thanks
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus 
>> signature database 4515 (20091016) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Preserving leading and trailing spaces XSSFCell

Posted by Dale Monti <dm...@linoma.com>.
Well... No one has responded to my post. Which usually means it cannot 
be done, or there is some incredibly obvious thing I am missing. If 
someone could verify which is the case I would appreciate it.

Thanks

Dale Monti wrote:
> I would like to have a string value in a cell that maintains the 
> leading and trailing spaces. If I set a String value in a cell with 
> leading and trailing spaces, the value seems to be preserved in the 
> XML, but does not display in Excel.
> For example:
> XSSFCell cell = row.createCell(0);
> cell.setCellValue("   XYZ   ");
>
> Yeilds <si><t>   XYZ   </t></si> in sharedStrings.xml but does not 
> display the spaces in Excel.
>
> If you just type the value in Excel you get
> <si><t xml:space="preserve">    XYZ    </t></si>
>
> How can I preserve these spaces using POI?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus 
> signature database 4515 (20091016) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org