How to set the cell style as text

Aug 23, 2010 at 8:10 AM
sheet1.GetRow(0).CreateCell(0).SetCellValue(111);
the cell value default as number.
How to set the
cell style as text???
Aug 27, 2010 at 9:54 PM

If I remember correctly you have to specifically set the celltype to be String.

Sep 9, 2010 at 2:24 PM

You can try this:

sheet1.GetRow(0).CreateCell(0, CellType.STRING).SetCellValue(111);

 

or this, to set default format in the specific column:

CellStyle cellStyle = workbook.CreateCellStyle();

cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");

sheet1.SetDefaultColumnStyle(0, cellStyle);

 

I hope helped ;)