Xceed Workbooks for .NET v3.0 Documentation
Xceed.Workbooks.NET Assembly / Xceed.Workbooks.NET Namespace / WorksheetCollection Class
Members Example


In This Topic
    WorksheetCollection Class
    In This Topic
    Represents a collection of Worksheets in the 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