简体   繁体   English

如何将单元格的背景色设置为任何RGB值?

[英]how to set cell's background color to any RGB value?

I'm trying to set a cell background color to an RGB value like this 我正在尝试将像元背景颜色设置为RGB值

    XSSFCellStyle  instructionStyle = wb.createCellStyle();
    instructionStyle.setWrapText(true);
    XSSFColor myColor = new XSSFColor(new java.awt.Color(0, 73,144));
    instructionStyle.setFillForegroundColor(myColor);
    instructionStyle.setAlignment(HorizontalAlignment.CENTER);

and even it compiles aside of being horizontally align to center there is no other effect on a cell's look.can someone tell me what's wrong with this code ?Thanks 甚至可以将其水平对齐以使其居中,但对单元格的外观没有其他影响。有人可以告诉我这段代码有什么问题吗?

您可以尝试添加以下内容吗?

instructionStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM