表头设置函数
/**
*
* Description: 单元格样式设置
* @param wb
* @author huangweicheng
* @date 2020/3/17
*/
private HSSFCellStyle exportExcelSetCellStyle(HSSFWorkbook wb){
HSSFCellStyle style = wb.createCellStyle();
/*背景色填充*/
// style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
// style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
/*设置字体*/
HSSFFont font = wb.createFont();
font.setFontName("仿宋_GB2312");
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 12);
style.setFont(font);
/*居中对齐*/
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
return style;
}
调用函数
效果