POI中背景颜色设置方法如下:
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillBackgroundColor(HSSFColor.TEAL.index); //设置背景色
cellStyle.setFillForegroundColor(HSSFColor.TEAL.index);// 设置前景色
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
附:HSSFColor颜色定义
色 | 执行结果 |
---|---|
HSSFColor.ROYAL_BLUE | |
HSSFColor.TEAL | |
HSSFColor.LIME | |
HSSFColor.PALE_BLUE | |
HSSFColor.AQUA | |
HSSFColor.GREEN | |
HSSFColor.TURQUOISE | |
HSSFColor.DARK_BLUE | |
HSSFColor.CORNFLOWER_BLUE | |
HSSFColor.OLIVE_GREEN | |
HSSFColor.WHITE | |
HSSFColor.LIGHT_TURQUOISE | |
HSSFColor.LEMON_CHIFFON | |
HSSFColor.LIGHT_GREEN | |
HSSFColor.BLUE | |
HSSFColor.DARK_RED | |
HSSFColor.CORAL | |
HSSFColor.RED | |
HSSFColor.LIGHT_YELLOW | |
HSSFColor.SKY_BLUE | |
HSSFColor.BROWN | |
HSSFColor.SEA_GREEN | |
HSSFColor.INDIGO | |
HSSFColor.MAROON | |
HSSFColor.GREY_80_PERCENT | |
HSSFColor.GREY_25_PERCENT | |
HSSFColor.DARK_GREEN | |
HSSFColor.YELLOW | |
HSSFColor.GOLD | |
HSSFColor.GREY_40_PERCENT | |
HSSFColor.DARK_TEAL | |
HSSFColor.PINK | |
HSSFColor.ORCHID | |
HSSFColor.LIGHT_BLUE | |
HSSFColor.LIGHT_CORNFLOWER_BLUE | |
HSSFColor.BLACK | |
HSSFColor.DARK_YELLOW | |
HSSFColor.VIOLET | |
HSSFColor.LAVENDER | |
HSSFColor.ROSE | |
HSSFColor.BLUE_GREY | |
HSSFColor.LIGHT_ORANGE | |
HSSFColor.ORANGE | |
HSSFColor.GREY_50_PERCENT |
作者:itmyhome
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/itmyhome1990/article/details/49800205