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]
DefaultPropertyReadOnlyItem(_
ByValrow1AsInteger,_
ByValcol1AsInteger,_
ByValrow2AsInteger,_
ByValcol2AsInteger_
)AsIRange
[C#]
IRangethis[
introw1,
intcol1,
introw2,
intcol2
]{get;}
[C++]
__propertyIRange*get_Item(
introw1,
intcol1,
introw2,
intcol2
);
[JScript]
returnValue = IRangeObject.Item( row1,col1,row2,col2 );
-or-
returnValue = IRangeObject( row1,col1,row2,col2 );

[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;
[VisualBasic]
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