
'Declaration
<DefaultMemberAttribute("Item")> Public Class WorksheetCollection Inherits WorkbookElement
'Usage
Dim instance As WorksheetCollection
[DefaultMember("Item")] public class WorksheetCollection : WorkbookElement
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(); }
System.Object
Xceed.Workbooks.NET.WorkbookElement
Xceed.Workbooks.NET.WorksheetCollection
Name | Description | |
---|---|---|
![]() | Count | Gets the number of Worksheet in the WorksheetCollection. The default is one Worksheet per Workbook. |
![]() | Item | Overloaded. Gets the Worksheet element that is located at the specified Id. The first worksheet starts at 0. |
Name | Description | |
---|---|---|
![]() | Add | Overloaded. This method allows to add a Worksheet to the WorksheetCollection. |
![]() | Contains | Returns true if the WorksheetCollection contains a Worksheet with the name “worksheetName”; returns false otherwise. |
![]() | Copy | Overloaded. This method is used to create a copy of a specific worksheet. The worksheet to be copied can be specified by its index, name or by using the Worksheet object itself. |
![]() | GetEnumerator | |
![]() | Insert | Overloaded. Adds a new Worksheet at the designated location. |
![]() | Move | Overloaded. Moves a Worksheet or a WorksheetRange to a selected location in the WorksheetCollection. |
![]() | Remove | Overloaded. Removes the Worksheet from the WorksheetCollection and offsets the index of the other Worksheets toward the deleted element. |
![]() | RemoveAt | Removes a Worksheet from the WorksheetCollection by using an index to locate it in the collection. |
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