NativeExcel 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]
public__gc__interfaceIWorksheets: publicIEnumerable


Use the Worksheets property to return an IWorksheets collection.


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);
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
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);


Namespace: NativeExcel

Assembly: NativeExcel (in NativeExcel.dll)

See Also

IWorksheets Members | NativeExcel Namespace | Worksheets Property | IWorksheet Interface