sheet.setColumnWidth(5, 50*255);
sheet.setColumnWidth(6, 15*255);
sheet.setColumnWidth(7, 20*255);
sheet.setColumnWidth(8, 10*255);
//创建第一行
XSSFRow row=sheet.createRow(0);
//表头样式
XSSFFont fonttitle=wb.createFont();
fonttitle.setItalic(true);
fonttitle.setFontName("微软雅黑");
fonttitle.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体
CellStyle styletitle = wb.createCellStyle();
styletitle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
styletitle.setFillPattern(CellStyle.SOLID_FOREGROUND);
styletitle.setFont(fonttitle);
styletitle.setBorderLeft(CellStyle.BORDER_THIN);
styletitle.setBorderRight(CellStyle.BORDER_THIN);
styletitle.setBorderTop(CellStyle.BORDER_THIN);
styletitle.setBorderBottom(CellStyle.BORDER_THIN);
//正文样式
//
XSSFFont fontRed=wb.createFont();
fontRed.setColor(HSSFColor.GREEN.index);
fontRed.setColor(IndexedColors.RED.getIndex());
fontRed.setFontName("微软雅黑");
fontRed.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体
fontRed.setFontHeightInPoints((short) 11);
CellStyle styleRed = wb.createCellStyle();
styleRed.setFont(fontRed);
styleRed.setBorderLeft(CellStyle.BORDER_THIN);
styleRed.setBorderRight(CellStyle.BORDER_THIN);
styleRed.setBorderTop(CellStyle.BORDER_THIN);
styleRed.setBorderBottom(CellStyle.BORDER_THIN);
XSSFFont fontGreen=wb.createFont();
fontGreen.setColor(IndexedColors.GREEN.getIndex());
fontGreen.setFontName("微软雅黑");
fontGreen.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体
fontGreen.setFontHeightInPoints((short) 11);
CellStyle styleGreen = wb.createCellStyle();
styleGreen.setFont(fontGreen);
styleGreen.setBorderLeft(CellStyle.BORDER_THIN);
styleGreen.setBorderRight(CellStyle.BORDER_THIN);
styleGreen.setBorderTop(CellStyle.BORDER_THIN);
styleGreen.setBorderBottom(CellStyle.BORDER_THIN);
XSSFFont fontBlack=wb.createFont();
fontBlack.setColor(IndexedColors.BLACK.getIndex());
fontBlack.setFontName("Arial");
fontBlack.setFontHeightInPoints((short) 9);
CellStyle styleBlack = wb.createCellStyle();
styleBlack.setFont(fontBlack);
styleBlack.setBorderLeft(CellStyle.BORDER_THIN);
styleBlack.setBorderRight(CellStyle.BORDER_THIN);
styleBlack.setBorderTop(CellStyle.BORDER_THIN);
styleBlack.setBorderBottom(CellStyle.BORDER_THIN);
//写入标题
for (int i = 0; i < title.size(); i++) {
XSSFCell cell=row.createCell(i, XSSFCell.CELL_TYPE_STRING);
cell.setCellValue(title.get(i));
cell.setCellStyle(styletitle);
}
// 写入内容行
for (int i = 0; i < datas.size(); i++) {
String[] rowvalue = datas.get(i);
XSSFRow nextrow = sheet.createRow(sheet.getLastRowNum() + 1);// 创建一行
for (int j = 0; j < rowvalue.length; j++) {
XSSFCell cell = nextrow
.createCell(j, XSSFCell.CELL_TYPE_STRING);
cell.setCellValue(new XSSFRichTextString(rowvalue[j]));
if (rowvalue[j].equals("Fail")) {
cell.setCellStyle(styleRed);
} else if (rowvalue[j].equals("Pass")) {