2、添加工具类
public voidexpoortExcelx(String title, String[] headers, String[] columns,
List list, OutputStream out, String pattern) throwsNoSuchMethodException, Exception{//创建工作薄
XSSFWorkbook workbook=newXSSFWorkbook();//创建表格
Sheet sheet=workbook.createSheet(title);//设置默认宽度
sheet.setDefaultColumnWidth(25);//创建样式
XSSFCellStyle style=workbook.createCellStyle();//设置样式
style.setFillForegroundColor(IndexedColors.GOLD.index);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);//生成字体
XSSFFont font=workbook.createFont();
font.setColor(IndexedColors.VIOLET.index);
font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//应用字体
style.setFont(font)