单元格添加指定颜色

public static XSSFColor fine = new XSSFColor(new Color(146, 208, 80));

XSSFCellStyle cloneStyle = ht.getWorkbook().createCellStyle();
cloneStyle = (XSSFCellStyle) cloneStyle.clone();
cloneStyle.setBorderBottom(BorderStyle.THIN);//下边框
cloneStyle.setBorderLeft(BorderStyle.THIN);//左边框
cloneStyle.setBorderTop(BorderStyle.THIN);//上边框
cloneStyle.setBorderRight(BorderStyle.THIN);//右边框
cloneStyle.setFillForegroundColor(fine);//前景色
cloneStyle.setFillBackgroundColor(fine);//背景色
cloneStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cloneStyle.setAlignment(HorizontalAlignment.CENTER);
cloneStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cell.setCellStyle(cloneStyle);

posted @ 2022-11-23 14:01  懂得归零  阅读(84)  评论(0编辑  收藏  举报