BorderCollection Class
Encapsulates a collection of Border objects.
Inheritance Hierarchy
SystemObject
  Aspose.CellsBorderCollection

Namespace: Aspose.Cells
Assembly: Aspose.Cells (in Aspose.Cells.dll) Version: 19.11.0.0 (19.11)
Syntax
[SerializableAttribute]
public class BorderCollection

The BorderCollection type exposes the following members.

Properties
  NameDescription
Public propertyDiagonalColor
Gets or sets the Color of Diagonal lines.
Public propertyDiagonalStyle
Gets or sets the style of Diagonal lines.
Public propertyItem
Gets the Border element at the specified index.
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSetColor
Sets the Color of all borders in the collection.
Public methodSetStyle
Sets the style of all borders of the collection.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Adding a new worksheet to the Excel object
workbook.Worksheets.Add();

//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];

//Accessing the "A1" cell from the worksheet
Cell cell = worksheet.Cells["A1"];

//Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!");

Style style = cell.GetStyle();

//Setting the line style of the top border
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thick;

//Setting the color of the top border
style.Borders[BorderType.TopBorder].Color = Color.Black;

//Setting the line style of the bottom border
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thick;

//Setting the color of the bottom border
style.Borders[BorderType.BottomBorder].Color = Color.Black;

//Setting the line style of the left border
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thick;

//Setting the color of the left border
style.Borders[BorderType.LeftBorder].Color = Color.Black;

//Setting the line style of the right border
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thick;

//Setting the color of the right border
style.Borders[BorderType.RightBorder].Color = Color.Black;

cell.SetStyle(style);

//Saving the Excel file
workbook.Save("C:\\book1.xls");

[VB.NET]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()

'Adding a new worksheet to the Workbook object
workbook.Worksheets.Add()

'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)

'Accessing the "A1" cell from the worksheet
Dim cell As Cell = worksheet.Cells("A1")

'Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!")

Dim style as Style = cell.GetStyle()

'Setting the line style of the top border
style.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thick

'Setting the color of the top border
style.Borders(BorderType.TopBorder).Color = Color.Black

'Setting the line style of the bottom border
style.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thick

'Setting the color of the bottom border
style.Borders(BorderType.BottomBorder).Color = Color.Black

'Setting the line style of the left border
style.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thick

'Setting the color of the left border
style.Borders(BorderType.LeftBorder).Color = Color.Black

'Setting the line style of the right border
style.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thick

'Setting the color of the right border
style.Borders(BorderType.RightBorder).Color = Color.Black

cell.SetStyle(style)

'Saving the Excel file
workbook.Save("C:\book1.xls")
See Also