Class ExcelColor

java.lang.Object
io.github.dornol.excelkit.excel.ExcelColor

public final class ExcelColor extends Object
Represents an RGB color for Excel header backgrounds and cell styling.

Provides commonly used color presets as static constants, and supports custom RGB values via of(int, int, int).


 // Using a preset
 ExcelWriter.create().headerColor(ExcelColor.STEEL_BLUE);

 // Using a custom RGB color
 ExcelWriter.create().headerColor(ExcelColor.of(180, 200, 220));
 
  • Field Details

    • WHITE

      public static final ExcelColor WHITE
      White (255, 255, 255).
    • BLACK

      public static final ExcelColor BLACK
      Black (0, 0, 0).
    • LIGHT_GRAY

      public static final ExcelColor LIGHT_GRAY
      Light gray (217, 217, 217).
    • GRAY

      public static final ExcelColor GRAY
      Gray (128, 128, 128).
    • DARK_GRAY

      public static final ExcelColor DARK_GRAY
      Dark gray (64, 64, 64).
    • RED

      public static final ExcelColor RED
      Red (255, 0, 0).
    • GREEN

      public static final ExcelColor GREEN
      Green (0, 128, 0).
    • BLUE

      public static final ExcelColor BLUE
      Blue (0, 0, 255).
    • YELLOW

      public static final ExcelColor YELLOW
      Yellow (255, 255, 0).
    • ORANGE

      public static final ExcelColor ORANGE
      Orange (255, 165, 0).
    • LIGHT_RED

      public static final ExcelColor LIGHT_RED
      Light red for backgrounds.
    • LIGHT_GREEN

      public static final ExcelColor LIGHT_GREEN
      Light green for backgrounds.
    • LIGHT_BLUE

      public static final ExcelColor LIGHT_BLUE
      Light blue for backgrounds.
    • LIGHT_YELLOW

      public static final ExcelColor LIGHT_YELLOW
      Light yellow for backgrounds.
    • LIGHT_ORANGE

      public static final ExcelColor LIGHT_ORANGE
      Light orange for backgrounds.
    • LIGHT_PURPLE

      public static final ExcelColor LIGHT_PURPLE
      Light purple for backgrounds.
    • PURPLE

      public static final ExcelColor PURPLE
      Purple (128, 0, 128).
    • PINK

      public static final ExcelColor PINK
      Pink (255, 192, 203).
    • TEAL

      public static final ExcelColor TEAL
      Teal (0, 128, 128).
    • CORAL

      public static final ExcelColor CORAL
      Coral (255, 127, 80).
    • STEEL_BLUE

      public static final ExcelColor STEEL_BLUE
      Steel blue (70, 130, 180).
    • FOREST_GREEN

      public static final ExcelColor FOREST_GREEN
      Forest green (34, 139, 34).
    • GOLD

      public static final ExcelColor GOLD
      Gold (255, 215, 0).
  • Method Details

    • of

      public static ExcelColor of(int r, int g, int b)
      Creates a custom color from RGB values.
      Parameters:
      r - Red component (0–255)
      g - Green component (0–255)
      b - Blue component (0–255)
      Returns:
      a new ExcelColor instance
    • getR

      public int getR()
      Returns the red component (0-255).
      Returns:
      red value
    • getG

      public int getG()
      Returns the green component (0-255).
      Returns:
      green value
    • getB

      public int getB()
      Returns the blue component (0-255).
      Returns:
      blue value
    • toRgb

      public int[] toRgb()
      Returns the color as an RGB array.
      Returns:
      {r, g, b} array