How to rotate text in a spreadsheet cell using Apache POI?
-
13-09-2019 - |
Question
How can I rotate the text within an HSSFCell class of Apache POI?
Solution
Use HSSFCellStyle, that class has a method called setRotation(short rotation) which will rotate the text. All you do is apply the cell style to a cell:
HSSFCellStyle myStyle = workbook.createCellStyle();
myStyle.setRotation((short)90);
HSSFCell c = row.createCell(columnNumber);
c.setCellStyle(myStyle);
OTHER TIPS
CellStyle cssVertical = wb.createCellStyle();
cssVertical.setFont(f);
cssVertical.setRotation((short)90);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow