XlFormatting.Border Property

Gets or sets border settings to be applied to a cell.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.1.Core.dll


public XlBorder Border { get; set; }

Property Value

Type Description

An XlBorder object that specifies a border style and color.


To add cell borders, use the Border property of the XlCellFormatting object which controls the format settings of worksheet cells. The XlBorder object’s members allow you to specify each particular border of a cell individually (for example, top, bottom, left or right border), or set all outside borders at once. For each border, you can select a line style and color.

To apply border settings to a cell, assign the specified XlCellFormatting instance to the IXlCell.Formatting property or pass it to the IXlCell.ApplyFormatting method as a parameter, as shown in the example below. Note that the XlCellFormatting object supports implicit conversion from the XlBorder object, so that you can directly apply border settings to a cell without using unnecessary cast operators. For more information on how to specify cell borders, refer to the How to: Add Cell Borders topic.


// Create a new document and begin to write it to the specified stream. 
using (IXlDocument document = exporter.CreateDocument(stream)) {

    // Specify formatting settings to be applied to document content.
    XlCellFormatting formatting = new XlCellFormatting();

    // Specify cell background color.
    formatting.Fill = XlFill.SolidFill(XlColor.FromArgb(0xCE, 0x8B, 0xDA));

    // Specify font settings (font name, color, size and style).
    formatting.Font = new XlFont();
    formatting.Font.Name = "MV Boli";
    formatting.Font.SchemeStyle = XlFontSchemeStyles.None;
    formatting.Font.Size = 16;
    formatting.Font.Color = Color.Wheat;
    formatting.Font.Bold = true;

    // Specify the alignment of cell content.
    formatting.Alignment = XlCellAlignment.FromHV(XlHorizontalAlignment.Center, XlVerticalAlignment.Center);

    // Specify outside border settings.
    formatting.Border = XlBorder.OutlineBorders(XlColor.FromArgb(0x47, 0x7B, 0xD1), XlBorderLineStyle.Thick);

    // Create a new worksheet. 
    using (IXlSheet sheet = document.CreateSheet()) {

        // Create the first column and set its width.
        using (IXlColumn column = sheet.CreateColumn())
            column.WidthInPixels = 180;

        // Create the first row in the worksheet.
        using (IXlRow row = sheet.CreateRow()){
            // Create a cell and specify its format settings.
            using (IXlCell cell = row.CreateCell())
                cell.Value = "Custom Format";
See Also