Java利用POI生成Excel强制换行

1. 首先在需要强制换行的单元格里使用poi的样式,并且把样式设定为自动换行

  1. HSSFCellStyle cellStyle=workbook.createCellStyle();       
  2. cellStyle.setWrapText(true);       
  3. cell.setCellStyle(cellStyle); 

2. 其次是在需要强制换行的单元格,使用/就可以实再强制换行

  1. HSSFCell cell = row.createCell((short)0);    
  2. cell.setCellStyle(cellStyle);                           
  3. cell.setCellValue(new HSSFRichTextString("hello/r/n world!"));
原文地址:https://www.cnblogs.com/zhang-boke/p/7243584.html