| | |
| | | |
| | | import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
| | | import com.alibaba.excel.write.metadata.style.WriteFont; |
| | | import com.yuanchu.mom.pojo.AuxiliaryOutputWorkingHours; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | public class StyleYearUtils { |
| | | /** |
| | |
| | | // 头的策略 |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | // 背景颜色 |
| | | headWriteCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex()); |
| | | // headWriteCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex()); |
| | | headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); |
| | | |
| | | // 字体 |
| | |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | |
| | | // 这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法显示背景颜色.头默认了 FillPatternType所以可以不指定 |
| | | contentWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
| | | // contentWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
| | | contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); |
| | | |
| | | // 设置字体 |
| | |
| | | contentWriteCellStyle.setWriteFont(contentWriteFont);//在样式用应用设置的字体; |
| | | |
| | | //设置样式; |
| | | // contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框; |
| | | // contentWriteCellStyle.setBottomBorderColor((short) 1);//设置底边框颜色; |
| | | contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框; |
| | | contentWriteCellStyle.setBottomBorderColor((short) 0);//设置底边框颜色; |
| | | contentWriteCellStyle.setBorderLeft(BorderStyle.THIN); //设置左边框; |
| | | contentWriteCellStyle.setLeftBorderColor((short) 1);//设置左边框颜色; |
| | | contentWriteCellStyle.setLeftBorderColor((short) 0);//设置左边框颜色; |
| | | contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置右边框; |
| | | contentWriteCellStyle.setRightBorderColor((short) 1);//设置右边框颜色; |
| | | contentWriteCellStyle.setRightBorderColor((short) 0);//设置右边框颜色; |
| | | contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边框; |
| | | contentWriteCellStyle.setTopBorderColor((short) 1); ///设置顶边框颜色; |
| | | contentWriteCellStyle.setTopBorderColor((short) 0); ///设置顶边框颜色; |
| | | |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 水平居中 |
| | | contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 |