What would happen if you set the Cellstyle to be 'Text' beforehand? I'm not familiar with XSSF, but HSSF has this:
This is RPG but you'll get the gist: Text = HssfWorkbook_createCellstyle( Book ); DataFmt = HssfWorkbook_createDataFormat( Book ); String = new_String( '@' ); NumFmt = HssfDataFormat_getFormat( DataFmt: String ); HssfcellStyle_setDataFormat( Text: NumFmt ); In this case I have a cellstyle variable called 'Text'. Dataformat = '@' (or the numeric index equivalent ) forces the cell that uses it to be character. Hope that helps. Cheers, Ken -----Original Message----- From: Sascha Rühlow [mailto:[email protected]] Sent: Thursday, March 07, 2013 8:54 AM To: [email protected] Subject: XSSFCell Problem with Cell.CELL_TYPE_STRING Hi, I am currently using apache poi 3.8 and have a little problem with String values set to a XSSFCell using setCellValue(). If the String starts with - or another character used in Excel formulas, the text is not formatted as text in Excel (like, when I am entering a ' before a numeric value to format them as text). So if I am trying to edit the text field in Excel, it is interpreted as a formula whats is not really what I want. Is it possible to build something like the manually entered ' when setting the cellValue? Here's the code I am using: cell = row.createCell(ID); cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue("-Test"); Can anybody help me? Best regards --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
