Apache poi Apache POI excel如何为单元格应用文本左上缩进
如何在ApachePOI中添加具有左文本对齐的左上缩进 我目前拥有的:Apache poi Apache POI excel如何为单元格应用文本左上缩进,apache-poi,alignment,indentation,Apache Poi,Alignment,Indentation,如何在ApachePOI中添加具有左文本对齐的左上缩进 我目前拥有的: private CellStyle setDateAndTimeCellStyle(XSSFWorkbook workbook, Font font) { CellStyle dateCellStyle = workbook.createCellStyle(); dateCellStyle.setWrapText(true); dateCellStyle.setAlignment(CellStyl
private CellStyle setDateAndTimeCellStyle(XSSFWorkbook workbook, Font font) {
CellStyle dateCellStyle = workbook.createCellStyle();
dateCellStyle.setWrapText(true);
dateCellStyle.setAlignment(CellStyle.ALIGN_LEFT);
dateCellStyle.setIndention(CellStyle.VERTICAL_TOP);
dateCellStyle.setFont(font);
dateCellStyle.setBorderTop(CellStyle.BORDER_THIN);
dateCellStyle.setBorderLeft(CellStyle.BORDER_THIN);
dateCellStyle.setBorderRight(CellStyle.BORDER_THIN);
return dateCellStyle;
}
CellStyle dateCellStyle = setDateAndTimeCellStyle(workbook, font);
您使用的是什么古老的
apachepoi
版本?CellStyle
中的常量已在版本3.17
中删除。当前版本为4.1.1
。和CellStyle.setIndention(短缩进)
从来没有使用常量,而是设置单元格中文本缩进的空格数。参数indent
给出从左侧缩进的空格数。据我所知,从顶部缩进是不可能的。您将如何在Excel
的GUI
中执行此操作?我使用的是3.0.2版。Excel GUI中有一个选项可以将缩进设置为顶部、中心或底部。有什么办法可以做到这一点吗?Whow版本3.0.2
。您还在使用Windows 3.11,是吗?但由于版本3.0.2
甚至没有类CellStyle
,我对此表示怀疑。我猜你指的是垂直对齐而不是缩进:CellStyle.setVerticalAlignment(CellStyle.vertical\u TOP)代码>,CellStyle.setVerticalAlignment(CellStyle.VERTICAL\u中心)代码>,CellStyle.setVerticalAlignment(CellStyle.VERTICAL\u底部)代码>或单元样式。设置垂直对齐(单元样式。垂直对齐)
.Correction,版本为4.0.1InApachePOI4.0.1
您显示的代码无法编译。不再有CellStyle.VERTICAL.*
常量。有一个参数作为align参数。