java poi设置Excel单元格颜色

CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);  //填充单元格
cellStyle.setFillForegroundColor(HSSFColor.RED.index);    //填红色
r.getCell(1).setCellStyle(cellStyle); 

猜你喜欢

转载自blog.csdn.net/weixin_41722928/article/details/85246467