Style.SetPatternColor

Style.SetPatternColor method

Sets the background color.

public void SetPatternColor(BackgroundType pattern, Color color1, Color color2)
ParameterTypeDescription
patternBackgroundTypeThe pattern.
color1ColorThe foreground color.
color2ColorThe background color. Only works when pattern is not BackgroundType.None and BackgroundType.Solid.

Examples

using System;
using Aspose.Cells;
using System.Drawing;

namespace AsposeCellsExamples
{
    public class StyleMethodSetPatternColorWithBackgroundTypeColorColorDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            Cell cell = worksheet.Cells["A1"];
            
            Style style = cell.GetStyle();
            style.SetPatternColor(BackgroundType.Solid, Color.Red, Color.Blue);
            cell.SetStyle(style);
            
            workbook.Save("SetPatternColorDemo.xlsx", SaveFormat.Xlsx);
        }
    }
}

See Also