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: [email protected]
For additional commands, e-mail: [email protected]


__________ 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: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to