本次用的poi的版本是4.1.2
 SXSSFWorkbook wb = new SXSSFWorkbook(); 
 CellStyle style = wb.createCellStyle();
 style.setAlignment(HSSFCellStyle.ALIGN_CENTER)
 style.setFillForegroundColor(IndexedColors.CORNFLOWER_BLUE.getIndex());// 设置背景色
 style.setFillPattern(FillPatternType.SOLID_FOREGROUND);

如果是3版本一下 
 style.setFillPattern(CellStyle.SOLID_FOREGROUND);

    上面的单元格颜色对应下面的英语颜色表示,从X1-X49 按顺序对应;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();        
HSSFCellStyle style = workbook.createCellStyle();
style.setFillBackgroundColor(HSSFColor.AQUA.index);
cell.setCellStyle(style);

参考  https://www.cnblogs.com/linvan/p/10860538.html

POI 设置单元格背景色,背景色编码与实际颜色对照表(SXSSFWorkbook4.1.2)相关推荐

  1. POI 设置单元格格式,单元格合并,自动列宽等

    POI 设置单元格格式,单元格合并,自动列宽等 设置单元格样式 设置单元格背景 设置单元格合并 解决合并单元格遗留空白边框问题 设置单元格列宽自适应 设置单元格样式 第一种:日期格式 cell.set ...

  2. poi设置单元格背景颜色

    Java使用poi可以很方便地导出Excel表格文件,同时可以设置各种样式,例如背景颜色.下面给出两个例子设置背景颜色,一个使用自带的颜色设置背景颜色,一个使用自定义颜色设置. 使用内置的颜色设置单元 ...

  3. java 自动行高,20191012——POI设置单元格自动行高(思路)

    在经过Jxls或者POI导出数据至excel中后,发现有的单元格内容太多,既没有自动换行,也没有自动增大行高.那如何通过Java代码来实现呢?请看下面步骤: (一)首先,将excel设置为最合适的行高 ...

  4. POI设置单元格自动行高的思路

    在经过Jxls或者POI导出数据至excel中后,发现有的单元格内容太多,既没有自动换行,也没有自动增大行高.那如何通过Java代码来实现呢?请看下面步骤: (一)首先,将excel设置为最合适的行高 ...

  5. 20191012——POI设置单元格自动行高(思路)

    在经过Jxls或者POI导出数据至excel中后,发现有的单元格内容太多,既没有自动换行,也没有自动增大行高.那如何通过Java代码来实现呢?请看下面步骤: (一)首先,将excel设置为最合适的行高 ...

  6. POI设置单元格格式

    /**设置单元格格式为文本格式*/ HSSFCellStyle textStyle = workBook.createCellStyle(); HSSFDataFormat format = work ...

  7. poi 设置单元格边框

    //设置单元格样式 CellStyle comm = workbook.createCellStyle(); comm.setAlignment(HorizontalAlignment.CENTER) ...

  8. poi设置单元格下拉下表

    poi是读写excel最常用的一个开源中间件,实际使用中我们可能会遇到这样的需求:限制某列单元格只能输入特定的内容,这就是excel的下拉列表特性,以下是wps中excel的一个截图: 从上图可以看出 ...

  9. poi 设置单元格背景色

    1 必须设置填充样式 cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); 2 设置背景色两种方法 注意,设置背景色用 foregro ...

最新文章

  1. tkinter实现弹出输入对话框并获取输入对话框中的值
  2. Algorand的共识协议及其核心的优势
  3. UIImage 裁剪图片和等比列缩放图片
  4. python解不定积分_python快速求解不定积分和定积分
  5. 黑客在数十个 WordPress 插件和主题中插入秘密后门,可发动供应链攻击
  6. Xshell连接VMware的linux系统
  7. 整体二分算法完整总结
  8. AppScan 的安装+激活以及+漏扫dvwa,生成安全报告
  9. 软件测试用例的书写方式以及测试模板
  10. 19款资源整合类网站推荐:每一个网站都堪称以一敌百
  11. 腾讯云 短信 简单使用
  12. 【算法随记二】线卷积积分及其在图像增强和特效方面的应用(一)
  13. win2008Server 部署网站
  14. Capstone/CS5211低成本替代昆泰CH7511B方案
  15. 单片机c51语言实训总结,单片机实训报告
  16. OCR表格识别—(一)
  17. 如何结交阿里P9,腾讯T4这样的大佬?
  18. offer比较:华为云核心网产品线和作业帮 都是开发
  19. (贰)笔记:AUI 中 Tab 的使用及 item 样式与下划线样式的修改
  20. 【孟子E章】祝大家新年愉快!

热门文章

  1. 如何在正则表达式里表达可能存在也可能不存在的内容?
  2. 周立功zlg600a 模块linux驱动
  3. js中身份证校验规则
  4. 史上最详细LRW数据集、LRW-1000数据集、LRS2数据集、LRS3-TED数据集、OuluVS2数据集介绍
  5. <Rasa实战> 内容摘要(四)
  6. TDS协议解析(转载)
  7. 注册德国商标的好处是什么
  8. Python全国二级等级考试 资源!
  9. Tita 绩效宝:让管理者提高1对1面谈水平的5大技巧
  10. 微信小程序input框在某些手机上获取数据失败