NativeExcel for .Net Developer's Reference

IRange.Borders Property

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

[Visual Basic]
Property ReadOnly Borders As IBorders
[C#]
IBorders Borders { get; }
[C++]
__property IBorders* get_Borders();
[JScript]
function get Borders() : 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;
[Visual Basic]
 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