NativeExcel for .Net Developer's Reference

IWorksheets.Item Property (Int32)

Returns an IWorksheet by using index numbers.

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

[Visual Basic]
DefaultPropertyReadOnlyItem(_
ByValindexAsInteger_
)AsIWorksheet
[C#]
IWorksheetthis[
intindex
]{get;}
[C++]
__propertyIWorksheet*get_Item(
intindex
);
[JScript]
returnValue = IWorksheetsObject.Item( index );
-or-
returnValue = IWorksheetsObject( index );

[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

index
A number that indicates the one-based index number of the worksheet you want to access.

Property Value

Returns an IWorksheet interface.

Example

This example removes the last worksheet.

[C#]
IWorksheets sheets = book.Worksheets;
sheets[sheets.Count].Delete(); 
[VisualBasic]
Dim sheets As IWorksheets
sheets = book.Worksheets
sheets(sheets.Count).Delete()
[C++]
IWorksheets* sheets = book->Worksheets;
sheets->Item[sheets->Count]->Delete(); 

See Also

IWorksheets Interface | NativeExcel Namespace | IWorksheets.Item Overload List | IWorksheet Interface | Worksheets Property