Nick, Mark and Gabriel:
thank you guys for replying, very appreciated.
After making the post, I was browsing through the API when I saw the
DataFormat class and its hierarchy, the BuiltinFormats class, and the
setDataFormat method of the CellStyle class. So did some experimentation,
and the code below seems to work!
XSSFCellStyle textFormatStyle = book.createCellStyle();
textFormatStyle.setDataFormat((short)BuiltinFormats.getBuiltinFormat("text"));
XSSFCell cell = row.createCell(columnIndex++);
cell.setCellStyle(textFormatStyle);
now, once spreadsheet is created, I can edit a cell, and when I tab out, the
format remains "text". I can still change it if I want to by doing right
click --> "Format Cells...", but at least it will not change on its own.
Thanks again guys for looking at this and the quick response, very
appreciated!
Regards
Sanjeev
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/How-to-set-Cell-Format-to-Text-tp3275568p3275966.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]