Syncfusion.XlsIO.Base
Example 


PatternColorIndex Property (IExtendedFormat)

Returns or sets the color of the interior pattern as an index into the current color palette.
Syntax
'Declaration
 
Property PatternColorIndex As ExcelKnownColors
'Usage
 
Dim instance As IExtendedFormat
Dim value As ExcelKnownColors
 
instance.PatternColorIndex = value
 
value = instance.PatternColorIndex
ExcelKnownColors PatternColorIndex {get; set;}
Example
The following code illustrates how to set a color from ExcelKnownColors enumeration to the pattern of the IStyle.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Set text
            worksheet["C2"].Text = "Sample";
            worksheet["E2"].Text = "Sample";
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set pattern
            style.FillPattern = ExcelPattern.VerticalStripe;
            
            //Set pattern color
            style.PatternColorIndex = ExcelKnownColors.Red;
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Get extended format
            IExtendedFormat format = worksheet["E2"].CellStyle;
            
            //Set pattern
            format.FillPattern = ExcelPattern.VerticalStripe;
            
            //Set pattern color
            format.PatternColorIndex = ExcelKnownColors.Red;
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also