/**设置单元格格式为文本格式*/ HSSFCellStyle textStyle = workBook.createCellStyle(); HSSFDataFormat format = workBook.createDataFormat(); //textStyle.setDataFormat(format.getFormat("@"));//text/@ textStyle.setDataFormat(format.getFormat("text"));//text/@ cell.setCellStyle(textStyle);//设置单元格格式为"文本" cell.setCellType(HSSFCell.CELL_TYPE_STRING); /**设置单元格格式为日期格式*/ HSSFCellStyle style0 = workbook.createCellStyle(); style0.setBorderBottom(HSSFCellStyle.BORDER_THIN); style0.setDataFormat(format.getFormat("m/d/yy h:mm"));//yyyy/MM/dd hh:mm:ss cell.setCellStyle(style0);