Enum ColorType

ColorType enumeration

Represents all color type

public enum ColorType

Values

NameValueDescription
Automatic0Automatic color.
AutomaticIndex1It’s automatic color,but the displayed color depends the setting of the OS System.
RGB2The RGB color.
IndexedColor3The color index in the color palette.
Theme4The theme color.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;
    using System.Drawing;

    public class ColorTypeDemo
    {
        public static void ColorTypeExample()
        {
            // Instantiate a new Workbook
            Workbook workbook = new Workbook();
            // Add a new worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // Accessing a cell from the worksheet
            Cell cell = worksheet.Cells["B2"];
            Style style = cell.GetStyle();

            // Setting the foreground color to yellow
            style.BackgroundColor = Color.Yellow;
            // Setting the background pattern to solid
            style.Pattern = BackgroundType.Solid;
            // Saving the modified style to the "B2" cell
            cell.SetStyle(style);

            // Adding custom color to the palette at 55th index
            Color customColor = Color.FromArgb(212, 213, 0);
            workbook.ChangePalette(customColor, 55);

            // Accessing another cell from the worksheet
            cell = worksheet.Cells["B3"];
            // Adding some value to the cell
            cell.PutValue("Hello Aspose!");

            // Creating a CellsColor object
            CellsColor cellsColor = workbook.CreateCellsColor();

            // Setting the RGB color
            cellsColor.Color = Color.Red;

            // Applying the color to a cell
            cell = worksheet.Cells["B4"];
            style = cell.GetStyle();
            style.ForegroundColor = cellsColor.Color;
            style.Pattern = BackgroundType.Solid;
            cell.SetStyle(style);

            // Save the workbook
            workbook.Save("ColorTypeExample.xlsx");
            workbook.Save("ColorTypeExample.pdf");
            return;
        }
    }
}

See Also