NativeExcel2 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]
returnValue = IRangeColumnsObject.Item( col );
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.


The one-based index number of the column

Property Value

Returns an IRangeColumn interface.


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

 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;    
 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 
 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