Reputation: 10216
Is there any way to write a cell with the "Vertical" text orientation available in Apache POI? I can only find a method setRotation that rotates the entire text, rather than have it as Excel displays it when the "Vertical" option is applied. Visually this will look like:
this text
becomes
t
h
i
s
t
e
x
t
Upvotes: 0
Views: 2258
Reputation: 48376
As per the HSSFCell.setRotation(short)
set the degree of rotation for the text in the cell
rotation - degrees (between -90 and 90 degrees, or 0xff for vertical)
So, you'll first need to create a (single, workbook-wide) cell style with that on:
CellStyle styleVertical = wb.createCellStyle();
styleVertical.setRotation(0xff);
Then apply that to your cell
Cell cell = row.createCell(0);
cell.setCellValue("this text");
cell.setCellStyle(styleVertical);
Upvotes: 3
Reputation: 2251
CellStyle cs = wb.createCellStyle();//where 'wb' is the workbook
cs.setWrapText(true);
cell.setCellStyle(cs);//where 'cell' is the cell you wish to edit
After that, the standard \n
can be used to make a new line in the cell.
Upvotes: 0