/**设置单元格格式为文本格式*/ HSSFCellStyle textStyle = workBook.createCellStyle(); HSSFDataFormat format = workBook.createDataFormat(); textStyle.setDataFormat(format.getFormat("@")); cell.setCellStyle(textStyle);//设置单元格格式为"文本" cell.setCellType(HSSFCell.CELL_TYPE_STRING);
-------
CellStyle textStyle = wb.createCellStyle();
DataFormat format = wb.createDataFormat();
textStyle.setDataFormat(format.getFormat("@"));
sheet.setDefaultColumnStyle(colNum, textStyle);