[]
This class converts color strings into Color objects that can be used in the APIs such as cell fill and border formatting. Use stringToColor(String) to create colors from standard color names, RGB and RGBA expressions, and hexadecimal color strings.
Color fillColor = ColorUtilities.stringToColor("rgba(255,0,0,0.5)");
Color borderColor = ColorUtilities.stringToColor("#000000");
worksheet.getRange("B2").getInterior().setColor(fillColor);
worksheet.getRange("B2").getBorders().setColor(borderColor);
static ColorstringToColor(String colorString) Color object.Color object.Supported formats include RGB expressions such as "rgb(255,0,0)", RGBA expressions such as "rgba(255,0,0,0.5)", hexadecimal values such as "#F00" and "#FF0000", hexadecimal values with alpha such as "#F00C" and "#FF0000CC", and predefined color names such as "red".
If the input cannot be parsed, this method returns a fully transparent color.
Color fillColor = ColorUtilities.stringToColor("rgba(255,0,0,0.5)");
worksheet.getRange("B2").getInterior().setColor(fillColor);
colorString - The color string to convert. This value may be null; if it cannot be parsed, a fully transparent color is returned.Color represented by colorString. Returns a fully transparent color if parsing fails.