[alibaba/easyexcel]单元格的背景色能添加RGB颜色吗,只能是自带的颜色吗

2024-05-09 536 views
6
   这里写你的代码

回答

3

可以设置 ,给你一段伪代码 Color你可以自定义

XSSFColor customColor = new XSSFColor(new java.awt.Color(128, 128, 128));
CellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(customColor);
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
Cell cell = row.createCell(0);
cell.setCellValue("Hello World");
cell.setCellStyle(style);
8

public void afterCellDispose(CellWriteHandlerContext context) { XSSFCellStyle cStyle = (XSSFCellStyle) context.getWriteWorkbookHolder().getWorkbook().createCellStyle(); cStyle.setFillForegroundColor(new XSSFColor(new Color(255, 192, 203))); cStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); context.getFirstCellData().setOriginCellStyle(cStyle); } 这样是可以的 setOriginCellStyle 之前没看见这个方法啊

6

解决了就好