NativeExcel2 for .Net Developer's Reference

IWorksheets Interface

A collection of all the IWorksheet interfaces in the specified workbook.

For a list of all members of this type, see IWorksheets Members.

[Visual Basic]
PublicInterfaceIWorksheets
ImplementsIEnumerable
[C#]
publicinterfaceIWorksheets:IEnumerable
[C++]
public__gc__interfaceIWorksheets: publicIEnumerable
[JScript]
publicinterfaceIWorksheetsextendsIEnumerable

Remarks

Use the Worksheets property to return an IWorksheets collection.

Example

[C#]
IWorkbook book = NativeExcel.Factory.OpenWorkbook("book.xls");
IWorksheets sheets;
if (book != null) {
   sheets = book.Worksheets;
   Console.WriteLine("Worksheets count: {0}", sheets.Count);
   for (int i = 1; i <= sheets.Count; i++) {
       Console.WriteLine("Sheet[{0}].Name={1}", i, sheets[i].Name);
   }    
}  
[VisualBasic]
Dim book As IWorkbook = NativeExcel.Factory.OpenWorkbook("book.xls")
Dim sheets As IWorksheets
Dim i As Integer 
If Not book Is Nothing Then
   sheets = book.Worksheets
   Console.WriteLine("Worksheets count: {0}", sheets.Count)
   For i = 1 To sheets.Count
       Console.WriteLine("Sheet[{0}].Name={1}", i, sheets(i).Name)
   Next i   
End If
[C++]
IWorkbook* book = NativeExcel::Factory::OpenWorkbook(S"book.xls");
IWorksheets* sheets;
if (book != null) {
   sheets = book->Worksheets;
   Console::WriteLine(S"Worksheets count: {0}", sheets->Count);
   for (int i = 1; i <= sheets->Count; i++) {
       Console::WriteLine(S"Sheet[{0}].Name={1}", i, sheets->Item[i]->Name);
   }    
}  

Requirements

Namespace: NativeExcel

Assembly: NativeExcel (in NativeExcel.dll)

See Also

IWorksheets Members | NativeExcel Namespace | Worksheets Property | IWorksheet Interface