POI生成Excel强制换行

自动换行的设置: 

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

强制换行:

<pre name="code" class="html">HSSFCell cell = row.createCell((short)0);      
cell.setCellStyle(cellStyle);                            
cell.setCellValue(new HSSFRichTextString("hello/r/n world!"));   

修改代码如码如下

HSSFCell cell = row.createCell((short)0);     
cellStyle.setWrapText(true);//先设置为自动换行     
cell.setCellStyle(cellStyle);                            
cell.setCellValue(new HSSFRichTextString("hello/r/n world!"));   

posted on 2015-08-19 09:59  dts  阅读(1300)  评论(0编辑  收藏  举报

导航