NativeExcel for .Net Developer's Reference

IWorksheets.Count Property

Returns the number of worksheets in the collection.

[Visual Basic]
Property ReadOnly Count As Integer
[C#]
int Count { get; }
[C++]
__property int get_Count();
[JScript]
function get Count() : int

Property Value

Integer. The number of worksheets in the IWorksheets collection.

Example

This example uses the Count property to set the value of A1 cell on the first sheet.

[C#]
book.Worksheets[1].Range["A1"].Value = book.Worksheets.Count;
[Visual Basic]
book.Worksheets(1).Range("A1").Value = book.Worksheets.Count
[C++]
book->Worksheets->Item[1]->Range->Item[S"A1"]->Value = book->Worksheets->Count;

See Also

IWorksheets Interface | NativeExcel Namespace