The easiest trick that I know of is to simply prefix the date string with a 
single inverted comma. Instead of writing this string to the cell;

10/10/2007

write this to the cell;

'10/10/2007

That informs Excel that it is to treat the cells contents as a sting.

Modha Khammammettu <[EMAIL PROTECTED]> wrote: Hi All

I am using POI to create excel spreadsheet.

Every cell I create for this spreadsheet, I create like

HSSFCell cell = row.createCell((short)cellNumber);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);

Now excel file gets created. The problem is when I open this excel file
to manually change lets say date value is a cell

1. Initially when the date is written I believe stored as text. (Ex:
12/4/2007)
2. When I manually open this spreadsheet and change the cell (12/5/2007)
the cell format is changed. It is no longer text. Excel does its own
thing (converts to date). I want all the cells to contain text only.

Is there some way I can say, In the spreadsheet I create using POI all
cells are text cells and even if it is opened using Excel and data is
changed the cell contents should still be text.

Please let me know.

Thanks


       
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.

Reply via email to