NativeExcel for .Net Developer's Reference

IRange.Item Property (Int32, Int32, Int32, Int32)

Returns an IRange interface that represents a cell or range of cells by using row and column index numbers.

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

[Visual Basic]
Default Property ReadOnly Item( _ 
   ByVal row1 As Integer, _ 
   ByVal col1 As Integer, _ 
   ByVal row2 As Integer, _ 
   ByVal col2 As Integer _ 
) As IRange
[C#]
IRange this[
   int row1,
   int col1,
   int row2,
   int col2
] { get; }
[C++]
__property IRange* get_Item(
   int row1,
   int col1,
   int row2,
   int col2
);
[JScript]
returnValue = IRangeObject.Item( row1col1row2col2 );
-or-
returnValue = IRangeObject( row1col1row2col2 );

[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

row1
A number that indicates the first row of the range, starting with 1 for the first row in the worksheet.
col1
A number that indicates the first column of the range, starting with 1 for the first column in the worksheet.
row2
A number that indicates the last row of the range, starting with 1 for the first row in the worksheet.
col2
A number that indicates the last column of the range, starting with 1 for the first column in the worksheet.

Property Value

Returns an IRange interface.

Example

This example sets the font style in cells A1:D10 on the first sheet to bold.

[C#]
book.Worksheets[1].Range[1, 1, 10, 4].Font.Bold = true;
[Visual Basic]
book.Worksheets(1).Range(1, 1, 10, 4).Font.Bold = True
[C++]
book->Worksheets->Item[1]->Range->Item[1, 1, 10, 4]->Font->Bold = true;

See Also

IRange Interface | NativeExcel Namespace | IRange.Item Overload List | How to reference Cells and Ranges