poi操作excel 单元格的换行
import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.ss.usermodel.Cell;import org.apache.poi.ss.usermodel.CellStyle;import org.apache.poi.ss.usermodel.Row;import org.apache.poi.ss.usermodel.Sheet;import org.apache.poi.ss.usermodel.Workbook;import java.io.FileOutputStream;/*** @ClassName 类名:ExcelDemo9* @Author作者: hzh* @Date时间:/12/4 15:48* 换行**/public class ExcelDemo9 {public static void main(String[] args) throws Exception{//获得一个工作薄Workbook wb = new HSSFWorkbook();//第一个sheetSheet sheet = wb.createSheet("第一个sheet");//创建第一行Row row = sheet.createRow(1);//获取第一个单元格(第一列)Cell cell = row.createCell(5);//给第一个单元格赋值cell.setCellValue("第一个单元格的值 \n 我是下一行");CellStyle cellStyle = wb.createCellStyle();cellStyle.setWrapText(true);cell.setCellStyle(cellStyle);row.setHeightInPoints(2*sheet.getDefaultRowHeightInPoints());sheet.autoSizeColumn(2);FileOutputStream fileOutputStream = new FileOutputStream("D://file//huanhang.xls");wb.write(fileOutputStream);wb.close();}}