一.流程逻辑
1.新建类继承AbstractVerticalCellStyleStrategy策略处理器重写方法,自定义设置某一列单元格的格式
2.新建一个注解类用在实体类中,用来标识某一列
3.自定义策略处理器进行注册
EasyExcel.write().registerWriteHandler(new CellStyleStrategyHandle());
二.实现要素
package com;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.util.StyleUtil;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.AbstractVerticalCellStyleStrategy;
import org.apache.poi.ss.usermodel.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
public class CellStyleStrategyHandle extends AbstractVerticalCellStyleStrategy {
private Workbook workbook;
private DataFormat dataFormat;
private Class aClass;
private WriteCellStyle writeCellStyle = new WriteCellStyle();
private Map<Integer, CellStyle> headCellStyleCache = new HashMap<Integer, CellStyle>();
private Map<Integer, CellStyle> contentCellStyleCache = new HashMap<Integer, CellStyle>();
private Map<Integer, Boolean> annotationCache = new HashMap<Integer, Boolean