alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    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
    IEnumerable.GetEnumerator()
    IParentApplication.Application
    IParentApplication.Parent
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.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
    Color
    Examples

    The following code illustrates how to set RGB color from 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
    int
    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

    this[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();
    }
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved