NativeExcel2 for .Net Developer's Reference

IWorksheets.Count Property

Returns the number of worksheets in the collection.

[Visual Basic]
PropertyReadOnlyCountAsInteger
[C#]
intCount{get;}
[C++]
__propertyintget_Count();
[JScript]
functiongetCount():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;
[VisualBasic]
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