Enum BorderType

BorderType enumeration

Enumerates the border line and diagonal line types.

[Flags]
public enum BorderType

Values

NameValueDescription
BottomBorder8Represents bottom border line.
DiagonalDown10Represents the diagonal line from top left to right bottom.
DiagonalUp20Represents the diagonal line from bottom left to right top.
LeftBorder1Represents left border line.
RightBorder2Represents right border line exists.
TopBorder4Represents top border line.
Horizontal80Only for dynamic style,such as conditional formatting.
Vertical40Only for dynamic style,such as conditional formatting.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;
    using System.Drawing;

    public class BorderTypeDemo
    {
        public static void BorderTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            // Access the first worksheet
            Worksheet worksheet = workbook.Worksheets[0];
            // Create a range of cells
            var range = worksheet.Cells.CreateRange("A1:D4");

            // Create a style object
            Style style = workbook.CreateStyle();
            // Set the borders for the range
            style.SetBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Black);
            style.SetBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);
            style.SetBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Black);
            style.SetBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
            style.SetBorder(BorderType.DiagonalDown, CellBorderType.Thin, Color.Red);
            style.SetBorder(BorderType.DiagonalUp, CellBorderType.Thin, Color.Blue);

            // Apply the style to the range
            StyleFlag flag = new StyleFlag { Borders = true };
            range.ApplyStyle(style, flag);

            // Save the workbook
            workbook.Save("BorderTypeExample.xlsx");
            workbook.Save("BorderTypeExample.pdf");
        }
    }
}

See Also