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

Java代码

HSSFCellStyle cellStyle=workbook.creatO & t U ^ @ feg = = v @ m \ MCellStyle();

cellStyle.setWrapText(true);

cell.setCellStyle(cellStyle);

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

Java代码

HSSFCell cell = row.createCelp 2 ! 0 a j W tl((short)0)x + w;

cell.setCellStyle(cellStyle); cell.setCellValue(new HSSFRichTextString(“hello\r\n world!”));

但是”hello\r\n world!”内容要是从数据库中读出来就不换行。} | v不知道从oracle数据库中读出来的字符串和自己写的字符串有何区别?

回答