Apache POI – HSSF单元格格式中的垂直单元格alignment
有没有办法用Apache POI中的“垂直”文本方向编写单元格? 我只能find一个方法setRotation旋转整个文本,而不是像Excel应用“垂直”选项时显示的那样。 在视觉上,这看起来像:
本文
变
t h i s t e x t
根据HSSFCell.setRotation(简称)
设置单元格中文本的旋转度
旋转 – 度(在-90和90度之间,或垂直为0xff)
因此,您首先需要创build一个(单一的,工作簿范围)单元格样式:
CellStyle styleVertical = wb.createCellStyle(); styleVertical.setRotation(0xff);
然后将其应用到您的手机
Cell cell = row.createCell(0); cell.setCellValue("this text"); cell.setCellStyle(styleVertical);
CellStyle cs = wb.createCellStyle();//where 'wb' is the workbook cs.setWrapText(true); cell.setCellStyle(cs);//where 'cell' is the cell you wish to edit
之后,标准\n
可以用来在单元格中创build一个新行。