//package com.ruoyi.utils.excel.easyexcel.handler;
//
//import com.alibaba.excel.metadata.CellData;
//import com.alibaba.excel.metadata.Head;
//import com.alibaba.excel.write.handler.CellWriteHandler;
//import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
//import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
//import org.apache.poi.ss.usermodel.*;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * excel通用单元格格式类
// */
//public class TemplateCellWriteHandler implements CellWriteHandler {
//
//    @Override
//    public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {
//
//    }
//
//    private final  Map<Object,CellStyle> cellStyleMap = new HashMap<>();
//
//    @Override
//    public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
//        Workbook workbooks = writeSheetHolder.getSheet().getWorkbook();
//        Sheet sheet = writeSheetHolder.getSheet();
//        sheet.setColumnWidth(cell.getColumnIndex(), 20 * 256);
//        sheet.setDefaultRowHeight((short) 700);
//
//
//        if (!cellStyleMap.containsKey("style1")){
//            CellStyle cellStyle = workbooks.createCellStyle();
//            cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//居中
//            cellStyle.setAlignment(HorizontalAlignment.CENTER);
//            cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置前景填充样式
//            cellStyle.setFillForegroundColor(IndexedColors.BLUE_GREY.getIndex());//前景填充色
//
//            // 设置边框样式
//            // 上边框
//            cellStyle.setBorderTop(BorderStyle.THIN);
//            // 下边框
//            cellStyle.setBorderBottom(BorderStyle.THIN);
//            // 左边框
//            cellStyle.setBorderLeft(BorderStyle.THIN);
//            // 右边框
//            cellStyle.setBorderRight(BorderStyle.THIN);
//
//
//            //设置字体
//            Font font1 = workbooks.createFont();
//            font1.setBold(true);
//            font1.setColor(IndexedColors.BLACK.getIndex());
//            font1.setFontHeightInPoints((short)15);
//            font1.setFontName("宋体");
//            cellStyle.setFont(font1);
//            cell.setCellStyle(cellStyle);
//
//            cellStyleMap.put("style1",cellStyle);
//        }else {
//            CellStyle cellStyle = cellStyleMap.get("style1");
//            cell.setCellStyle(cellStyle);
//        }
//
//
//        //其他列
//        if (!isHead){
//            if (!cellStyleMap.containsKey("style2")){
//                CellStyle style = workbooks.createCellStyle();
//                DataFormat dataFormat = workbooks.createDataFormat();
//                style.setDataFormat(dataFormat.getFormat("@"));
//                style.setVerticalAlignment(VerticalAlignment.CENTER);
//                style.setAlignment(HorizontalAlignment.CENTER);
//                cell.setCellStyle(style);
//                cellStyleMap.put("style2",style);
//            }else {
//                CellStyle cellStyle = cellStyleMap.get("style2");
//                cell.setCellStyle(cellStyle);
//            }
//
//        }
//    }
//
//    @Override
//    public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
//
//    }
//
//
//    @Override
//    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
//    }
//}
