Enum BorderType

BorderType enumeration

Enumerates the border line and diagonal line types.

[Flags]
public enum BorderType

Values

NameValueDescription
LeftBorder1Represents left border line.
RightBorder2Represents right border line exists.
TopBorder4Represents top border line.
BottomBorder8Represents bottom border line.
DiagonalDown10Represents the diagonal line from top left to right bottom.
DiagonalUp20Represents the diagonal line from bottom left to right top.
Vertical40Only for dynamic style, such as conditional formatting.
Horizontal80Only for dynamic style, such as conditional formatting.
SideBordersFIndicates the four side borders: LeftBorder, RightBorder, TopBorder and BottomBorder.
Diagonal30Special combination of multiple borders for user’s convenience for some APIs. Indicates diagonal borders of DiagonalUp and DiagonalDown.
DynamicStyleBordersC0Indicates Vertical and Horizontal of dynamic style.
None0No border has been specified.

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