POI设置颜色

POI中背景颜色设置方法如下:
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("sheet1");
HSSFRow row = sheet.createRow(0);
CellStyle style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
HSSFCell cell = row.createCell(i);//建立新cell
cell.setCellStyle(style);

颜色类型是在HSSFColorhuo或者IndexedColors在里面定义的.
                执行结果
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  
posted @ 2015-01-13 14:53  饺子吃遍天  阅读(504)  评论(0编辑  收藏  举报