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 "); Yields <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> POI should have some way of preserving these spaces. Thanks
Fixed in r830492 The fix looks easy on the surface but it took quite a while to understand how to do it with XmlBeans. xml:space="preserve" belongs to the Official XML Namespace (http://www.w3.org/XML/1998/namespace) and XmlBeans does not generate get/set accessors to it. It turned out that the only way to set this attribute is via XmlCursor, see the patch. Yegor