Set the foreground color background color in POI Excel

Source: Internet
Author: User

Set the foreground color background color in POI Excel

Set the background color in POI as follows:

HSSFCellStyle cellStyle = wb. createCellStyle (); cellStyle. setFillBackgroundColor (HSSFColor. TEAL. index); // set the background color cellStyle. setFillForegroundColor (HSSFColor. TEAL. index); // set the foreground color cellStyle. setFillPattern (HSSFCellStyle. SOLID_FOREGROUND );

Appendix: HSSFColor color definition

Color Execution result
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  

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.