NativeExcel for .Net Developer's Reference

IRangeColumns.Item Property (Int32)

Returns an IRangeColumn interface that represents a column by using column index number.

[C#] In C#, this property is the indexer for the IRangeColumns class.

[Visual Basic]
DefaultPropertyReadOnlyItem(_
ByValcolAsInteger_
)AsIRangeColumn
[C#]
IRangeColumnthis[
intcol
]{get;}
[C++]
__propertyIRangeColumn*get_Item(
intcol
);
[JScript]
returnValue = IRangeColumnsObject.Item( col );
-or-
returnValue = IRangeColumnsObject( col );

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.

Parameters

col
The one-based index number of the column

Property Value

Returns an IRangeColumn interface.

Example

This example changes the format for every second column on sheet one to bold.

[C#]
 IRangeColumns cols = book.Worksheets[1].UsedRange.Columns;
 bool bold = false;
 for (int col = 1; col <= cols.Count; col++) {
     cols[col].Font.Bold = bold;
     bold = !bold;    
 }
[VisualBasic]
 Dim cols As IRangeColumns = book.Worksheets(1).UsedRange.Columns
 Dim bold As Boolean = False
 For col As Integer = 1 To cols.Count
    cols(col).Font.Bold = bold
    bold = Not(bold)
 Next col 
[C++]
 IRangeColumns* cols = book->Worksheets->Item[1]->UsedRange->Columns;
 bool bold = false;
 for (int col = 1; col <= cols->Count; col++) {
     cols->Item[col]->Font->Bold = bold;
     bold = !bold;    
 }

See Also

IRangeColumns Interface | NativeExcel Namespace | IRangeColumns.Item Overload List | IRangeColumn Interface | IRange.Columns Property