poi 操作excel 自动换行 | 您所在的位置:网站首页 › excel换行显示怎么弄 › poi 操作excel 自动换行 |
https://www.oschina.net/question/113402_54946
1. 首先在需要强制换行的单元格里使用poi的样式,并且把样式设定为自动换行 Java代码 HSSFCellStyle cellStyle=workbook.createCellStyle(); cellStyle.setWrapText(true); cell.setCellStyle(cellStyle); 2. 其次是在需要强制换行的单元格,使用\就可以实再强制换行 Java代码 HSSFCell cell = row.createCell((short)0); cell.setCellStyle(cellStyle); cell.setCellValue(new HSSFRichTextString("hello\r\n world!")); 但是"hello\r\n world!"内容要是从数据库中读出来就不换行。不知道从oracle数据库中读出来的字符串和自己写的字符串有何区别? |
CopyRight 2018-2019 实验室设备网 版权所有 |