officefileapi-devexpress-dot-spreadsheet-dot-border.md
Gets or sets the line style of the cell border.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
BorderLineStyle LineStyle { get; set; }
Property LineStyle As BorderLineStyle
| Type | Description |
|---|---|
| BorderLineStyle |
A BorderLineStyle enumeration member.
|
Available values:
Show 14 items
| Name | Description | Example |
|---|---|---|
| None |
A border is not painted.
| | | Thin |
The thin solid border line.
|
| | Medium |
The medium solid border line.
|
| | Dashed |
The thin dashed border line.
|
| | Dotted |
The thin dotted border line.
|
| | Thick |
The thick solid border line.
|
| | Double |
The double border line.
|
| | Hair |
The hair border line.
|
| | MediumDashed |
The medium dashed border line.
|
| | DashDot |
The thin dash-dotted border line.
|
| | MediumDashDot |
The medium dash-dotted border line.
|
| | DashDotDot |
The thin dash-dot-dotted border line.
|
| | MediumDashDotDot |
The medium dash-dot-dotted border line.
|
| | SlantDashDot |
The medium slanted dash-dotted border line.
|
|
To set the cell border color, use the Border.Color property. If you specify the Border.Color for a border without setting its LineStyle, the border line style is automatically set to BorderLineStyle.Thin.
For more information on how to customize cell borders, refer to the following article:
Read Tutorial: How to: Add and Remove Cell Borders
This example demonstrates how to specify different borders for individual cells and ranges of cells by modifying the Borders object.
Worksheet worksheet = workbook.Worksheets[0];
// Set each particular border for the cell.
Cell cellB2 = worksheet.Cells["B2"];
Borders cellB2Borders = cellB2.Borders;
cellB2Borders.LeftBorder.LineStyle = BorderLineStyle.MediumDashDot;
cellB2Borders.LeftBorder.Color = Color.Pink;
cellB2Borders.TopBorder.LineStyle = BorderLineStyle.MediumDashDotDot;
cellB2Borders.TopBorder.Color = Color.HotPink;
cellB2Borders.RightBorder.LineStyle = BorderLineStyle.MediumDashed;
cellB2Borders.RightBorder.Color = Color.DeepPink;
cellB2Borders.BottomBorder.LineStyle = BorderLineStyle.Medium;
cellB2Borders.BottomBorder.Color = Color.Red;
cellB2Borders.DiagonalBorderType = DiagonalBorderType.Up;
cellB2Borders.DiagonalBorderLineStyle = BorderLineStyle.Thick;
cellB2Borders.DiagonalBorderColor = Color.Red;
// Set diagonal borders for the cell.
Cell cellC4 = worksheet.Cells["C4"];
Borders cellC4Borders = cellC4.Borders;
cellC4Borders.SetDiagonalBorders(Color.Orange, BorderLineStyle.Double, DiagonalBorderType.UpAndDown);
// Set all outside borders for the cell in one step.
Cell cellD6 = worksheet.Cells["D6"];
cellD6.Borders.SetOutsideBorders(Color.Gold, BorderLineStyle.Double);
// Set all borders for the range of cells in one step.
CellRange range1 = worksheet.Range["B8:F13"];
range1.Borders.SetAllBorders(Color.Green, BorderLineStyle.Double);
// Set all inside and outside borders separately for the range of cells.
CellRange range2 = worksheet.Range["C15:F18"];
range2.SetInsideBorders(Color.SkyBlue, BorderLineStyle.MediumDashed);
range2.Borders.SetOutsideBorders(Color.DeepSkyBlue, BorderLineStyle.Medium);
// Set all horizontal and vertical borders separately for the range of cells.
CellRange range3 = worksheet.Range["D21:F23"];
Formatting range3Formatting = range3.BeginUpdateFormatting();
Borders range3Borders = range3Formatting.Borders;
range3Borders.InsideHorizontalBorders.LineStyle = BorderLineStyle.MediumDashDot;
range3Borders.InsideHorizontalBorders.Color = Color.DarkBlue;
range3Borders.InsideVerticalBorders.LineStyle = BorderLineStyle.MediumDashDotDot;
range3Borders.InsideVerticalBorders.Color = Color.Blue;
range3.EndUpdateFormatting(range3Formatting);
// Set each particular border for the range of cell.
CellRange range4 = worksheet.Range["E25:F26"];
Formatting range4Formatting = range4.BeginUpdateFormatting();
Borders range4Borders = range4Formatting.Borders;
range4Borders.SetOutsideBorders(Color.Black, BorderLineStyle.Thick);
range4Borders.LeftBorder.Color = Color.Violet;
range4Borders.TopBorder.Color = Color.Violet;
range4Borders.RightBorder.Color = Color.DarkViolet;
range4Borders.BottomBorder.Color = Color.DarkViolet;
range4Borders.DiagonalBorderType = DiagonalBorderType.UpAndDown;
range4Borders.DiagonalBorderLineStyle = BorderLineStyle.MediumDashed;
range4Borders.DiagonalBorderColor = Color.BlueViolet;
range4.EndUpdateFormatting(range4Formatting);
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Set each particular border for the cell.
Dim cellB2 As Cell = worksheet.Cells("B2")
Dim cellB2Borders As Borders = cellB2.Borders
cellB2Borders.LeftBorder.LineStyle = BorderLineStyle.MediumDashDot
cellB2Borders.LeftBorder.Color = Color.Pink
cellB2Borders.TopBorder.LineStyle = BorderLineStyle.MediumDashDotDot
cellB2Borders.TopBorder.Color = Color.HotPink
cellB2Borders.RightBorder.LineStyle = BorderLineStyle.MediumDashed
cellB2Borders.RightBorder.Color = Color.DeepPink
cellB2Borders.BottomBorder.LineStyle = BorderLineStyle.Medium
cellB2Borders.BottomBorder.Color = Color.Red
cellB2Borders.DiagonalBorderType = DiagonalBorderType.Up
cellB2Borders.DiagonalBorderLineStyle = BorderLineStyle.Thick
cellB2Borders.DiagonalBorderColor = Color.Red
' Set diagonal borders for the cell.
Dim cellC4 As Cell = worksheet.Cells("C4")
Dim cellC4Borders As Borders = cellC4.Borders
cellC4Borders.SetDiagonalBorders(Color.Orange, BorderLineStyle.Double, DiagonalBorderType.UpAndDown)
' Set all outside borders for the cell in one step.
Dim cellD6 As Cell = worksheet.Cells("D6")
cellD6.Borders.SetOutsideBorders(Color.Gold, BorderLineStyle.Double)
' Set all borders for the range of cells in one step.
Dim range1 As CellRange = worksheet.Range("B8:F13")
range1.Borders.SetAllBorders(Color.Green, BorderLineStyle.Double)
' Set all inside and outside borders separately for the range of cells.
Dim range2 As CellRange = worksheet.Range("C15:F18")
range2.SetInsideBorders(Color.SkyBlue, BorderLineStyle.MediumDashed)
range2.Borders.SetOutsideBorders(Color.DeepSkyBlue, BorderLineStyle.Medium)
' Set all horizontal and vertical borders separately for the range of cells.
Dim range3 As CellRange = worksheet.Range("D21:F23")
Dim range3Formatting As Formatting = range3.BeginUpdateFormatting()
Dim range3Borders As Borders = range3Formatting.Borders
range3Borders.InsideHorizontalBorders.LineStyle = BorderLineStyle.MediumDashDot
range3Borders.InsideHorizontalBorders.Color = Color.DarkBlue
range3Borders.InsideVerticalBorders.LineStyle = BorderLineStyle.MediumDashDotDot
range3Borders.InsideVerticalBorders.Color = Color.Blue
range3.EndUpdateFormatting(range3Formatting)
' Set each particular border for the range of cell.
Dim range4 As CellRange = worksheet.Range("E25:F26")
Dim range4Formatting As Formatting = range4.BeginUpdateFormatting()
Dim range4Borders As Borders = range4Formatting.Borders
range4Borders.SetOutsideBorders(Color.Black, BorderLineStyle.Thick)
range4Borders.LeftBorder.Color = Color.Violet
range4Borders.TopBorder.Color = Color.Violet
range4Borders.RightBorder.Color = Color.DarkViolet
range4Borders.BottomBorder.Color = Color.DarkViolet
range4Borders.DiagonalBorderType = DiagonalBorderType.UpAndDown
range4Borders.DiagonalBorderLineStyle = BorderLineStyle.MediumDashed
range4Borders.DiagonalBorderColor = Color.BlueViolet
range4.EndUpdateFormatting(range4Formatting)
The following code snippets (auto-collected from DevExpress Examples) contain references to the LineStyle property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
rangeFormatting.Fill.BackgroundColor = Color.DarkGray;
rangeFormatting.Borders.InsideHorizontalBorders.LineStyle = BorderLineStyle.Thin;
rangeFormatting.Borders.InsideHorizontalBorders.Color = Color.Gray;
// Display vertical inside borders within the table.
formatting.Borders.InsideVerticalBorders.LineStyle = BorderLineStyle.Thin;
formatting.Borders.InsideVerticalBorders.Color = Color.White;
See Also