Syncfusion.XlsIO.Base
Example 


ColorIndex Property (IExtendedFormat)

Returns or sets the color from ExcelKnownColors enumeration to the IStyle.
Syntax
'Declaration
 
Property ColorIndex As ExcelKnownColors
'Usage
 
Dim instance As IExtendedFormat
Dim value As ExcelKnownColors
 
instance.ColorIndex = value
 
value = instance.ColorIndex
ExcelKnownColors ColorIndex {get; set;}
Example
The following code illsutrates how to set a color from ExcelKnownColors enumeration to the ColorIndex property.
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];
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set color
            style.ColorIndex = ExcelKnownColors.Red;
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Get extended format
            IExtendedFormat format = worksheet["E2"].CellStyle;
            
            //Set color
            format.ColorIndex = ExcelKnownColors.Red;
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also