A while ago in a school scheduling system, there is a place to use the curriculum generated Excel to export to the customer, because the previous use of Excel is simply a simple application, in the cell is the use of automatic line, and this time may need to use to manually force a newline.
So I found on the Internet, the article found on the Internet is to say in the text in Excel plus/n,/n/r,/r/n and so on, anyway, all kinds of have, and even more strange is that some people say in the cell plus <br>
Later I tried to use the/R after the effect is generated in the file, you use the open, and will not wrap, if you use the mouse in the cell after a click on the line will be automatically wrapped.
Then I thought about it and could do it the following way,
1. First use the POI style in the cells that need to be forced to wrap, and set the style to wrap
Hssfcellstyle cellstyle=Workbook.createcellstyle (); Cellstyle.setwraptext (true); Cell.setcellstyle (CellStyle);
2. Next, in the cells that need to be forced to wrap, use/to force a newline
Hssfcell cell = Row.createcell ((short) 0); Cell.setcellstyle (CellStyle);
Cell.setcellvalue (New
This makes it possible to force a line break,
The effect of line break is to force a line break in the cell.
// Hello // world!
Java uses POI to generate Excel to force line breaks