content: package com.fit2cloud.common.utils;
  
  import com.alibaba.excel.write.metadata.style.WriteCellStyle;
  import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
  import org.apache.poi.ss.usermodel.BorderStyle;
  import org.apache.poi.ss.usermodel.HorizontalAlignment;
  import org.apache.poi.ss.usermodel.IndexedColors;
  import org.apache.poi.ss.usermodel.VerticalAlignment;
  
  /**
   * 自定义样式样式
   *
   * @author jianneng
   **/
  public class EasyExcelUtils {
      /**
       * 设置excel样式
       */
      public static HorizontalCellStyleStrategy getStyleStrategy() {
          // 头的策略  样式调整
          WriteCellStyle headWriteCellStyle = new WriteCellStyle();
          // 头背景 浅灰
          headWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
          // 自动换行
          headWriteCellStyle.setWrapped(true);
          // 设置细边框
          headWriteCellStyle.setBorderBottom(BorderStyle.THIN);
          headWriteCellStyle.setBorderLeft(BorderStyle.THIN);
          headWriteCellStyle.setBorderRight(BorderStyle.THIN);
          headWriteCellStyle.setBorderTop(BorderStyle.THIN);
          // 设置边框颜色 25灰度
          headWriteCellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
          headWriteCellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
          headWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
          headWriteCellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
          // 水平对齐方式
          headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
          // 垂直对齐方式
          headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  
          // 内容的样式
          WriteCellStyle contentStyle = new WriteCellStyle();
          // 自动换行
          contentStyle.setWrapped(true);
          // 设置垂直居中
          contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  
          // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
          return new HorizontalCellStyleStrategy(headWriteCellStyle, contentStyle);
      }
  }
  