menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface IBorders - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface IBorders

    A collection of four Border objects that represent the four borders of a Range or Style object.

    Inherited Members
    IParentApplication.Application
    IParentApplication.Parent
    System.Collections.IEnumerable.GetEnumerator()
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.Base.dll
    Syntax
    public interface IBorders : IEnumerable, IParentApplication

    Properties

    Color

    Returns or sets the color from or to all the IBorder in the IBorders collection.

    Declaration
    ExcelKnownColors Color { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Remarks

    To set color for individual borders, we can use Color or ColorRGB property.

    Examples

    The following code illustrates how to set color from ExcelKnownColors enumeration to all the IBorder in the IBorders collection.

            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["D2"].Text = "text";
                worksheet["C3"].Text = "in";
                worksheet["D3"].Text = "cell";
    
                //Set borders
                IBorders borders = worksheet["C2:D3"].Borders;
    
                //Set color
                borders.Color = ExcelKnownColors.Red;
    
                //Set line style
                borders.LineStyle = ExcelLineStyle.Thick;
    
                //Save and dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
            }

    ColorRGB

    Returns or sets RGB color from or to all the IBorder in the IBorders collection.

    Declaration
    Color ColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples

    The following code illustrates how to set RGB color from System.Drawing.Color structure to all the IBorder in the IBorders collection.

            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["D2"].Text = "text";
                worksheet["C3"].Text = "in";
                worksheet["D3"].Text = "cell";
    
                //Set borders
                IBorders borders = worksheet["C2:D3"].Borders;
    
                //Set color
                borders.ColorRGB = System.Drawing.Color.Red;
    
                //Set line style
                borders.LineStyle = ExcelLineStyle.Thick;
    
                //Save and dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
            }

    Count

    Returns the number of IBorder objects in the IBorders collection. Read-only, Long.

    Declaration
    int Count { get; }
    Property Value
    Type
    System.Int32
    Examples

    The following code illustrates how to access Count property.

            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 borders
                IBorders borders = worksheet["C2"].Borders;
    
                //Check count
                Console.Write(borders.Count);
    
                //Save and Dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
                Console.ReadKey();
            }
    //Output will be
    //6

    Item[ExcelBordersIndex]

    Returns a IBorder object that represents one of the IBorders of either a IRange of cells or a IStyle.

    Declaration
    IBorder this[ExcelBordersIndex Index] { get; }
    Parameters
    Type Name Description
    ExcelBordersIndex Index
    Property Value
    Type
    IBorder
    Examples

    The following code illustrates how to access IBorder using ExcelBordersIndex from the IBorders collection.

            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["D2"].Text = "text";
                worksheet["C3"].Text = "in";
                worksheet["D3"].Text = "cell";
    
                //Set borders
                IBorders borders = worksheet["C2:D3"].Borders;
    
                //Set color
                borders.Color = ExcelKnownColors.Red;
    
                //Set line style
                borders.LineStyle = ExcelLineStyle.Thick;
    
                //Set diagonal line visibility
                borders[ExcelBordersIndex.DiagonalDown].ShowDiagonalLine = false;
                borders[ExcelBordersIndex.DiagonalUp].ShowDiagonalLine = false;
    
                //Save and dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
            }

    LineStyle

    Returns or sets the line style for the IBorder. Read / write ExcelLineStyle.

    Declaration
    ExcelLineStyle LineStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples

    The following code illustrates how to set LineStyle to all the IBorder in the IBorders collection.

            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 borders
                IBorders borders = worksheet["C2:D3"].Borders;
    
                //Set color
                borders.Color = ExcelKnownColors.Red;
    
                //Set line style
                borders.LineStyle = ExcelLineStyle.Thick;
    
                //Save and dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
            }

    Value

    Synonym for Borders.LineStyle. Read / write.

    Declaration
    ExcelLineStyle Value { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples

    The following code illustrates how to set Value to all the IBorder in the IBorders collection.

            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 borders
                IBorders borders = worksheet["C2:D3"].Borders;
    
                //Set color
                borders.Color = ExcelKnownColors.Red;
    
                //Set line style
                borders.Value = ExcelLineStyle.Thick;
    
                //Save and dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
            }

    Extension Methods

    FunctionalExtensions.ForEach<T>(IEnumerable, Action<T>)
    FunctionalExtensions.ToList<T>(IEnumerable)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved