NativeExcel2 for .Net Developer's Reference

IBorders Interface

Collection of four IBorder interfaces that represent the four borders of a Range. Use the Borders property to return the IBorders collection, which contains all four borders. Use Borders[index], where index identifies the border, to return a single IBorder interface.

For a list of all members of this type, see IBorders Members.

[Visual Basic]
PublicInterfaceIBorders
[C#]
publicinterfaceIBorders
[C++]
public__gc__interfaceIBorders
[JScript]
publicinterfaceIBorders

Example

The following example adds a double red border to cell A1 on worksheet one.

[C#]
IBorders borders = book.Worksheets[1].Range["A1"].Borders;
borders.LineStyle = XlLineStyle.xlDouble; 
borders.Color = System.Drawing.Color.Red;
[VisualBasic]
Dim borders As IBorders = book.Worksheets(1).Range("A1").Borders 
borders.LineStyle = XlLineStyle.xlDouble 
borders.Color = System.Drawing.Color.Red
[C++]
IBorders* borders = book->Worksheets->Item[1]->Range->Item[S"A1"]->Borders;
borders->LineStyle = XlLineStyle::xlDouble;
borders->Color = System::Drawing::Color::Red;
The following example sets the color of the bottom border of cells A1:G1 to red.
[C#]
book.Worksheets[1].Range["A1","G1"].Borders[XlBordersIndex.xlEdgeBottom].Color = Color.FromArgb(255, 0, 0);
[VisualBasic]
book.Worksheets(1).Range("A1","G1").Borders(XlBordersIndex.xlEdgeBottom).Color = Color.FromArgb(255, 0, 0)
[C++]
book->Worksheets->Item[1]->Range->Item[S"A1",S"G1"]->Borders->Item[XlBordersIndex::xlEdgeBottom]->Color = Color::FromArgb(255, 0, 0);

Requirements

Namespace: NativeExcel

Assembly: NativeExcel (in NativeExcel.dll)

See Also

IBorders Members | NativeExcel Namespace | IRange.Borders Property