开发中碰到一个很怪的问题,设置单元格的属性是string了,显示如“0000123”也正确了,但是双击后又变成了数字,现在用这个方式解决了,但是没有搞清楚具体的原因,可能要接着继续研究一下,在此先记录一下
HSSFRichTextString richString = new HSSFRichTextString(textValue);
HSSFDataFormat df = workbook.createDataFormat();
HSSFCellStyle cs = cell.getCellStyle();
cs.setDataFormat(df.getFormat("@"));
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellStyle(cs);
cell.setCellValue(richString);