Range.SetOutlineBorder

SetOutlineBorder(BorderType, CellBorderType, CellsColor)

Sets outline border around a range of cells.

public void SetOutlineBorder(BorderType borderEdge, CellBorderType borderStyle, 
    CellsColor borderColor)
ParameterTypeDescription
borderEdgeBorderTypeBorder edge.
borderStyleCellBorderTypeBorder style.
borderColorCellsColorBorder color.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class RangeMethodSetOutlineBorderWithBorderTypeCellBorderTypeCellsCDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            Cells cells = worksheet.Cells;

            // Create a CellsColor object
            CellsColor color = workbook.CreateCellsColor();
            color.ThemeColor = new ThemeColor(ThemeColorType.Accent2, 0);

            // Create a range and set right border
            Aspose.Cells.Range range = cells.CreateRange("A2:B3");
            range.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Thin, color);

            // Create another range and set all borders
            range = cells.CreateRange("C6:F10");
            range.SetOutlineBorders(CellBorderType.Thin, color);

            // Save the workbook
            workbook.Save("SetOutlineBorderExample.xlsx");
        }
    }
}

See Also


SetOutlineBorder(BorderType, CellBorderType, Color)

Sets outline border around a range of cells.

public void SetOutlineBorder(BorderType borderEdge, CellBorderType borderStyle, Color borderColor)
ParameterTypeDescription
borderEdgeBorderTypeBorder edge.
borderStyleCellBorderTypeBorder style.
borderColorColorBorder color.

Examples

using System;
using System.Drawing;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class RangeMethodSetOutlineBorderWithBorderTypeCellBorderTypeColorDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Create a range of cells
            Aspose.Cells.Range range = worksheet.Cells.CreateRange("A1:D5");

            // Set outline borders with different border types and colors
            range.SetOutlineBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Red);
            range.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Medium, Color.Blue);
            range.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Dashed, Color.Green);
            range.SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Double, Color.Black);

            // Save the workbook
            workbook.Save("RangeOutlineBorderDemo.xlsx");
        }
    }
}

See Also