Java 导出Excel 设置单元格样式
// 设置字体以及单元格格式
CellStyle format = workbook.createCellStyle();
XSSFFont wfont = workbook.createFont();
wfont.setFontName("楷书");
wfont.setFontHeightInPoints((short) 12);
format.setFont(wfont);
format.setAlignment(HorizontalAlignment.LEFT);
format.setVerticalAlignment(VerticalAlignment.TOP);
// 创建表头
XSSFRow header = sheet.createRow(0);
// 第二行写入标题
for (int i = 0; i < nameList.size(); i++) {
Cell cell = header.createCell(i);
cell.setCellValue(nameList.get(i));
cell.setCellStyle(blackStyle);
}