

'Declaration<DefaultMemberAttribute("Item")> Public Class WorksheetCollection Inherits WorkbookElement
'UsageDim 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. |
.NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.
.NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.