How do I change the Text Color and the Fillcolor

后端 未结 3 575
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 08:44

How do I change the header font color to white and the fill green? These are the classes that I am using:

import static org.apache.poi.ss.usermodel.CellStyl         


        
3条回答
  •  盖世英雄少女心
    2020-12-15 09:16

    If you want to set the color as simple cellstyle... you can write code like.

     cell.setCellValue("Header Text");
     XSSFCellStyle headerStyle = wb.createCellStyle();
     Font headerFont = wb.createFont();
     headerStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());
     headerFont.setColor(IndexedColors.WHITE.getIndex());
     headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
     headerStyle.setFont(headerFont);
     cell.setCellStyle(headerStyle);
    

    This will fill the cell with GREEN color and the font will be of Bold WHITE color

提交回复
热议问题