Xceed Workbooks for .NET v1.4 Documentation
WorksheetCollection Class
Members  Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace : WorksheetCollection Class
Represents a collection of Worksheet in a Workbook.
Object Model
WorksheetCollection ClassWorksheet Class
Syntax
'Declaration

 

<DefaultMemberAttribute("Item")>

Public Class WorksheetCollection 

   Inherits WorkbookElement
'Usage

 

Dim instance As WorksheetCollection
[DefaultMember("Item")]

public class WorksheetCollection : WorkbookElement 
Example
using( var doc = Workbook.Load( "test.xlsx") )   // Loads an existing Workbook named “test.xlsx”.

  {

    var worksheetA = doc.Worksheets[ 1 ];         // Gets the second worksheet. 

    var worksheetB = doc.Worksheets[ “Sheet3” ];         // Gets the worksheet named “Sheet3”. 

    doc.Worksheets.Add();                                   // Adds a new Worksheet.

    doc.Worksheets.Add( "ThirdSheet" );         // Adds a new Worksheet with a specific name.

    if( doc.Worksheets.Contains( "ThirdSheet" ) ) // Looks for a specific Worksheet.

      {

        Debug.WriteLine( "Found" );

      }

    doc.Save(); 

  }
Inheritance Hierarchy

System.Object
   Xceed.Workbooks.NET.WorkbookElement
      Xceed.Workbooks.NET.WorksheetCollection

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

WorksheetCollection Members
Xceed.Workbooks.NET Namespace