如何使用Apache POI在电子表格单元中旋转文本?

时间:2022-05-06 19:13:27

How can I rotate the text within an HSSFCell class of Apache POI?

如何在Apache POI的HSSFCell类中旋转文本?

2 个解决方案

#1


21  

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,该类有一个名为setRotation(short rotation)的方法,可以旋转文本。你所要做的就是将单元格样式应用到单元格中:

HSSFCellStyle myStyle = workbook.createCellStyle();
myStyle.setRotation((short)90);

HSSFCell c = row.createCell(columnNumber);
c.setCellStyle(myStyle);

#2


0  

CellStyle cssVertical = wb.createCellStyle();
cssVertical.setFont(f);
cssVertical.setRotation((short)90);

#1


21  

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,该类有一个名为setRotation(short rotation)的方法,可以旋转文本。你所要做的就是将单元格样式应用到单元格中:

HSSFCellStyle myStyle = workbook.createCellStyle();
myStyle.setRotation((short)90);

HSSFCell c = row.createCell(columnNumber);
c.setCellStyle(myStyle);

#2


0  

CellStyle cssVertical = wb.createCellStyle();
cssVertical.setFont(f);
cssVertical.setRotation((short)90);