POI设置单元格背景色,IndexedColors 编码 颜色 对照

转载自:https://www.cnblogs.com/linvan/p/10860538.html

HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
style.setFillForegroundColor(IndexedColors.CORNFLOWER_BLUE.getIndex());// 设置背景色
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //设置加粗

HSSFFont font = wb.createFont();
font.setFontName("黑体");
font.setFontHeightInPoints((short) 12);//设置字体大小
style.setFont(font);

// 创建标题
for (int i = 0; i < title.length; i++) {
    cell = row.createCell(i);
    cell.setCellValue(title[i]);
    cell.setCellStyle(style);
}

在这里插入图片描述
上面的单元格颜色对应下面的英语颜色表示,从X1-X49 按顺序对应;
将下面对应的code填入上述代码加粗斜体位置即可。

IndexedColors.AQUA.getIndex();
        IndexedColors.AUTOMATIC.getIndex(); 
        IndexedColors.BLUE.getIndex(); 
        IndexedColors.BLUE_GREY.getIndex();
        IndexedColors.BRIGHT_GREEN.getIndex();
        IndexedColors.BROWN.getIndex();
        IndexedColors.CORAL.getIndex();
        IndexedColors.CORNFLOWER_BLUE.getIndex();
        IndexedColors.DARK_BLUE.getIndex();
        IndexedColors.DARK_GREEN.getIndex();
        IndexedColors.DARK_RED.getIndex();
        IndexedColors.DARK_TEAL.getIndex();
        IndexedColors.DARK_YELLOW.getIndex();
        IndexedColors.GOLD.getIndex();
        IndexedColors.GREEN.getIndex();
        IndexedColors.GREY_25_PERCENT.getIndex();
        IndexedColors.GREY_40_PERCENT.getIndex();
        IndexedColors.GREY_50_PERCENT.getIndex();
        IndexedColors.GREY_80_PERCENT.getIndex();
        IndexedColors.INDIGO.getIndex();
        IndexedColors.LAVENDER.getIndex();
        IndexedColors.LEMON_CHIFFON.getIndex();
        IndexedColors.LIGHT_BLUE.getIndex();
        IndexedColors.LEMON_CHIFFON.getIndex();
        IndexedColors.LIGHT_BLUE.getIndex();
        IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex();
        IndexedColors.LIGHT_GREEN.getIndex();
        IndexedColors.LIGHT_ORANGE.getIndex();
        IndexedColors.LIGHT_TURQUOISE.getIndex();
        IndexedColors.LIGHT_YELLOW.getIndex();
        IndexedColors.LIME.getIndex();
        IndexedColors.MAROON.getIndex();
        IndexedColors.OLIVE_GREEN.getIndex();
        IndexedColors.ORANGE.getIndex();
        IndexedColors.ORCHID.getIndex();
        IndexedColors.PALE_BLUE.getIndex();
        IndexedColors.PINK.getIndex();
        IndexedColors.PLUM.getIndex();
        IndexedColors.RED.getIndex();
        IndexedColors.ROSE.getIndex();
        IndexedColors.ROYAL_BLUE.getIndex();
        IndexedColors.SEA_GREEN.getIndex();
        IndexedColors.SKY_BLUE.getIndex();
        IndexedColors.TAN.getIndex();
        IndexedColors.TEAL.getIndex();
        IndexedColors.TURQUOISE.getIndex();
        IndexedColors.VIOLET.getIndex();
        IndexedColors.WHITE.getIndex();
        IndexedColors.YELLOW.getIndex();
  • 5
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值