1.单元格字体标红
CellStyle algin_center_style1 = wb.createCellStyle();
algin_center_style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
algin_center_style1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
algin_center_style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setBorderTop(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setWrapText(true);
Font font = wb.createFont();
font.setColor(HSSFColor.RED.index);
algin_center_style1.setFont(font);
//设置格式
DataFormat format= wb.createDataFormat();
//标题栏居中单元格样式并加粗
CellStyle algin_center_style = wb.createCellStyle();
algin_center_style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
algin_center_style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
algin_center_style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
algin_center_style.setBorderRight(HSSFCellStyle.BORDER_THIN);
algin_center_style.setBorderTop(HSSFCellStyle.BORDER_THIN);
algin_center_style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
algin_center_style.setWrapText(true);
Font font = wb.createFont();
font.setFontName("仿宋_GB2312");
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
font.setFontHeightInPoints((short) 10);
algin_center_style.setFont(font);
//普通单元格居中
CellStyle algin_center_style1 = wb.createCellStyle();
algin_center_style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
algin_center_style1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
algin_center_style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setBorderTop(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
algin_center_style1.setWrapText(true);
//设置金额加粗并居右
Font font1 = wb.createFont();
font1.setFontName("仿宋_GB2312");
font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
algin_center_style.setFont(font);
//居右粗体
CellStyle algin_right_bold = wb.createCellStyle();
algin_right_bold.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
algin_right_bold.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
algin_right_bold.setBorderLeft(HSSFCellStyle.BORDER_THIN);
algin_right_bold.setBorderRight(HSSFCellStyle.BORDER_THIN);
algin_right_bold.setBorderTop(HSSFCellStyle.BORDER_THIN);
algin_right_bold.setBorderBottom(HSSFCellStyle.BORDER_THIN);
algin_right_bold.setWrapText(true);
algin_right_bold.setFont(font1);
algin_right_bold.setDataFormat(format.getFormat("#,##0.00"));
//居右不加粗
CellStyle algin_right_style = wb.createCellStyle();
algin_right_style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
algin_right_style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
algin_right_style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
algin_right_style.setBorderRight(HSSFCellStyle.BORDER_THIN);
algin_right_style.setBorderTop(HSSFCellStyle.BORDER_THIN);
algin_right_style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
algin_right_style.setWrapText(true);
algin_right_style.setDataFormat(format.getFormat("#,##0.00"));
//居中单元格日期样式
CellStyle algin_center_date = wb.createCellStyle();
algin_center_date.setAlignment(HSSFCellStyle.ALIGN_CENTER);
algin_center_date.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
algin_center_date.setBorderLeft(HSSFCellStyle.BORDER_THIN);
algin_center_date.setBorderRight(HSSFCellStyle.BORDER_THIN);
algin_center_date.setBorderTop(HSSFCellStyle.BORDER_THIN);
algin_center_date.setBorderBottom(HSSFCellStyle.BORDER_THIN);
algin_center_date.setWrapText(true);
algin_center_date.setDataFormat(format.getFormat("yyyy/M/d"));