|  |  | 
 |  |  |     private static final String DEFAULT_SHEET_NAME = "Sheet1"; | 
 |  |  |  | 
 |  |  |     private Class<T> modelClass; | 
 |  |  |     private static int maxrows = 50000; | 
 |  |  |  | 
 |  |  |     private ExcelExporter(){} | 
 |  |  |  | 
 |  |  | 
 |  |  |                 // 设置列头单元格 | 
 |  |  |                 configHeaderCell(sxssfWorkbook, cell, column.columnConfig); | 
 |  |  |             } | 
 |  |  |             List<CellStyle> styleList = new ArrayList<>(); | 
 |  |  |             for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { | 
 |  |  |                 ColumnInfo column = columns.get(columnIndex); | 
 |  |  |                 styleList.add( configDataCell(sxssfWorkbook,   column.columnConfig)); | 
 |  |  |             } | 
 |  |  |             // 创建数据记录 | 
 |  |  |             for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) { | 
 |  |  |                 Row row = sheet.createRow(rowIndex + 2); | 
 |  |  | 
 |  |  |                     ColumnInfo column = columns.get(columnIndex); | 
 |  |  |                     Cell cell = row.createCell(columnIndex); | 
 |  |  |                     cell.setCellValue(getCellData(column, data.get(rowIndex))); | 
 |  |  |  | 
 |  |  |                     // 设置数据单元格 | 
 |  |  |                     configDataCell(sxssfWorkbook, cell, column.columnConfig); | 
 |  |  |  | 
 |  |  |                     cell.setCellStyle(styleList.get(columnIndex)); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             sheet.addMergedRegion(new CellRangeAddress(data.size()+2   ,data.size()+2,0,this.getColumns().size()-1)); | 
 |  |  |             Row endRow = sheet.createRow(data.size()+2); | 
 |  |  | //            endRow.setHeight((short) 600); | 
 |  |  |             Cell c1 = endRow.createCell(0); | 
 |  |  |             c1.setCellValue(end); | 
 |  |  |             configEndCell(sxssfWorkbook,c1); | 
 |  |  |             c1.setCellStyle(  configEndCell(sxssfWorkbook)); | 
 |  |  |             sxssfWorkbook.write(os); | 
 |  |  |             os.close(); | 
 |  |  |         } catch (Exception e) { | 
 |  |  | 
 |  |  |         SXSSFWorkbook sxssfWorkbook; | 
 |  |  |         try { | 
 |  |  |             sxssfWorkbook = new SXSSFWorkbook(); | 
 |  |  |             Sheet sheet = sxssfWorkbook.createSheet(sheetName); | 
 |  |  |             // 创建列头 | 
 |  |  |             sheet.createFreezePane(0, 1); | 
 |  |  |             Row header = sheet.createRow(0); | 
 |  |  |             List<ColumnInfo> columns = this.getColumns(); | 
 |  |  |             for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { | 
 |  |  |                 ColumnInfo column = columns.get(columnIndex); | 
 |  |  |                 Cell cell = header.createCell(columnIndex); | 
 |  |  |                 cell.setCellValue(column.columnConfig.name()); | 
 |  |  |                 // 列宽设置 | 
 |  |  |                 if (column.columnConfig.width() == -1) { | 
 |  |  |                     sheet.setColumnWidth(columnIndex, column.columnConfig.name().length() * 2 * 256); | 
 |  |  |                 } else { | 
 |  |  |                     sheet.setColumnWidth(columnIndex, column.columnConfig.width() * 2 * 256); | 
 |  |  |             int totalSheet =1; | 
 |  |  |             if( data!=null && data.size()>0){ | 
 |  |  |                 totalSheet = data.size()/maxrows; | 
 |  |  |                 if(data.size()%maxrows !=0){ | 
 |  |  |                     totalSheet += 1; | 
 |  |  |                 } | 
 |  |  |                 // 设置列头单元格 | 
 |  |  |                 configHeaderCell(sxssfWorkbook, cell, column.columnConfig); | 
 |  |  |             } | 
 |  |  |             // 创建数据记录 | 
 |  |  |             for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) { | 
 |  |  |                 Row row = sheet.createRow(rowIndex + 1); | 
 |  |  |                 for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { | 
 |  |  |                     ColumnInfo column = columns.get(columnIndex); | 
 |  |  |                     Cell cell = row.createCell(columnIndex); | 
 |  |  |                     cell.setCellValue(getCellData(column, data.get(rowIndex))); | 
 |  |  |  | 
 |  |  |                     // 设置数据单元格 | 
 |  |  |                     configDataCell(sxssfWorkbook, cell, column.columnConfig); | 
 |  |  |  | 
 |  |  |             for (int i = 0; i < totalSheet; i++) { | 
 |  |  |                 List<T> list = null; | 
 |  |  |                 if(data.size() < maxrows * (i+1)) { | 
 |  |  |                     list = data.subList(maxrows*i,data.size()); | 
 |  |  |                 }else{ | 
 |  |  |                     list = data.subList(maxrows*i,maxrows*(i+1)); | 
 |  |  |                 } | 
 |  |  |                 createSheetDataBiz(list,"【"+(i+1)+"】"+sheetName,sxssfWorkbook); | 
 |  |  |             } | 
 |  |  |             sxssfWorkbook.write(os); | 
 |  |  |             os.close(); | 
 |  |  | 
 |  |  |                 } catch (IOException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void createSheetDataBiz(List<T> data, String sheetName, SXSSFWorkbook sxssfWorkbook) throws Exception{ | 
 |  |  |         Sheet sheet = sxssfWorkbook.createSheet(sheetName); | 
 |  |  |         // 创建列头 | 
 |  |  |         sheet.createFreezePane(0, 1); | 
 |  |  |         Row header = sheet.createRow(0); | 
 |  |  |         List<ColumnInfo> columns = this.getColumns(); | 
 |  |  |         for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { | 
 |  |  |             ColumnInfo column = columns.get(columnIndex); | 
 |  |  |             Cell cell = header.createCell(columnIndex); | 
 |  |  |             cell.setCellValue(column.columnConfig.name()); | 
 |  |  |             // 列宽设置 | 
 |  |  |             if (column.columnConfig.width() == -1) { | 
 |  |  |                 sheet.setColumnWidth(columnIndex, column.columnConfig.name().length() * 2 * 256); | 
 |  |  |             } else { | 
 |  |  |                 sheet.setColumnWidth(columnIndex, column.columnConfig.width() * 2 * 256); | 
 |  |  |             } | 
 |  |  |             // 设置列头单元格 | 
 |  |  |             configHeaderCell(sxssfWorkbook, cell, column.columnConfig); | 
 |  |  |         } | 
 |  |  |         List<CellStyle> styleList = new ArrayList<>(); | 
 |  |  |         for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { | 
 |  |  |             ColumnInfo column = columns.get(columnIndex); | 
 |  |  |             styleList.add( configDataCell(sxssfWorkbook,   column.columnConfig)); | 
 |  |  |         } | 
 |  |  |         // 创建数据记录 | 
 |  |  |         for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) { | 
 |  |  |             Row row = sheet.createRow(rowIndex + 1); | 
 |  |  |             for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { | 
 |  |  |                 ColumnInfo column = columns.get(columnIndex); | 
 |  |  |                 Cell cell = row.createCell(columnIndex); | 
 |  |  |                 cell.setCellValue(getCellData(column, data.get(rowIndex))); | 
 |  |  |                 // 设置数据单元格样式 | 
 |  |  |                 cell.setCellStyle(styleList.get(columnIndex)); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 配置数据单元格 | 
 |  |  |      */ | 
 |  |  |     private void configDataCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig) { | 
 |  |  |         CellStyle style = workbook.createCellStyle(); | 
 |  |  |         style.setAlignment(columnConfig.align()); | 
 |  |  |         style.setVerticalAlignment(VerticalAlignment.CENTER); | 
 |  |  |         // 设置背景 | 
 |  |  |         style.setFillPattern(FillPatternType.SOLID_FOREGROUND); | 
 |  |  |         style.setFillForegroundColor(columnConfig.dataBackgroundColor().getIndex()); | 
 |  |  |         // 字体 | 
 |  |  |         Font font = workbook.createFont(); | 
 |  |  |         font.setFontHeightInPoints(columnConfig.fontSize()); | 
 |  |  |         // 字体颜色 | 
 |  |  |         font.setColor(columnConfig.color().getIndex()); | 
 |  |  |         // 粗体 | 
 |  |  |         font.setBold(columnConfig.bold()); | 
 |  |  |         // 斜体 | 
 |  |  |         font.setItalic(columnConfig.italic()); | 
 |  |  |         style.setFont(font); | 
 |  |  |         // 边框 | 
 |  |  |         configCellBorder(style); | 
 |  |  |         style.setWrapText(true); | 
 |  |  |         cell.setCellStyle(style); | 
 |  |  |     private CellStyle configDataCell (SXSSFWorkbook workbook, ExcelColumn columnConfig) { | 
 |  |  |             CellStyle  configDataCellStyle = workbook.createCellStyle(); | 
 |  |  |             configDataCellStyle.setAlignment(columnConfig.align()); | 
 |  |  |             configDataCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); | 
 |  |  |             // 设置背景 | 
 |  |  |             configDataCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | 
 |  |  |             configDataCellStyle.setFillForegroundColor(columnConfig.dataBackgroundColor().getIndex()); | 
 |  |  |             // 字体 | 
 |  |  |             Font font = workbook.createFont(); | 
 |  |  |             font.setFontHeightInPoints(columnConfig.fontSize()); | 
 |  |  |             // 字体颜色 | 
 |  |  |             font.setColor(columnConfig.color().getIndex()); | 
 |  |  |             // 粗体 | 
 |  |  |             font.setBold(columnConfig.bold()); | 
 |  |  |             // 斜体 | 
 |  |  |             font.setItalic(columnConfig.italic()); | 
 |  |  |             configDataCellStyle.setFont(font); | 
 |  |  |             // 边框 | 
 |  |  |             configCellBorder(configDataCellStyle); | 
 |  |  |             configDataCellStyle.setWrapText(true); | 
 |  |  |  | 
 |  |  |         return configDataCellStyle; | 
 |  |  | //        cell.setCellStyle(configDataCellStyle); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         configCellBorder(style); | 
 |  |  |         cell.setCellStyle(style); | 
 |  |  |     } | 
 |  |  | //    public static CellStyle configEndCellStyle =null; | 
 |  |  |     /** | 
 |  |  |      * 配置列头单元格 | 
 |  |  |      */ | 
 |  |  |     private void configEndCell (SXSSFWorkbook workbook, Cell cell ) { | 
 |  |  |     private CellStyle configEndCell (SXSSFWorkbook workbook ) { | 
 |  |  |         CellStyle style = workbook.createCellStyle(); | 
 |  |  |         style.setAlignment(HorizontalAlignment.RIGHT); | 
 |  |  |         style.setVerticalAlignment(VerticalAlignment.CENTER); | 
 |  |  | 
 |  |  |         style.setFont(font); | 
 |  |  |         // 设置边框 | 
 |  |  |         configCellBorder(style); | 
 |  |  |         cell.setCellStyle(style); | 
 |  |  |         return style; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** |