NativeExcel2 for .Net Developer's Reference

IRange.Borders Property

Returns an IBorders interface that represents the borders of the specified range.

[Visual Basic]
PropertyReadOnlyBordersAsIBorders
[C#]
IBordersBorders{get;}
[C++]
__propertyIBorders*get_Borders();
[JScript]
functiongetBorders():IBorders

Property Value

IBorders interface.

Example

This example sets the color of the bottom border of cell B2 on sheet one to a thin red border.

[C#]
 IBorders borders;
 borders = book.Worksheets[1].Range["B2"].Borders;
 borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
 borders[XlBordersIndex.xlEdgeBottom].Weight = XlBorderWeight.xlThin;
 borders[XlBordersIndex.xlEdgeBottom].ColorIndex = 3;
[VisualBasic]
 Dim borders As IBorders
 borders = book.Worksheets(1).Range("B2").Borders
 borders(XlBordersIndex.xlEdgeBottom).LineStyle = XlLineStyle.xlContinuous
 borders(XlBordersIndex.xlEdgeBottom).Weight = XlBorderWeight.xlThin
 borders(XlBordersIndex.xlEdgeBottom).ColorIndex = 3
[C++]
 IBorders* borders;
 borders = book->Worksheets->Item[1]->Range->Item[S"B2"]->Borders;
 borders->Item[XlBordersIndex::xlEdgeBottom]->LineStyle = XlLineStyle::xlContinuous;
 borders->Item[XlBordersIndex::xlEdgeBottom]->Weight = XlBorderWeight::xlThin;
 borders->Item[XlBordersIndex::xlEdgeBottom]->ColorIndex = 3;

See Also

IRange Interface | NativeExcel Namespace | IBorders Interface | IBorder Interface | XlBordersIndex Enumeration