WorksheetCollection Class
Encapsulates a collection of Worksheet objects.
Inheritance Hierarchy
SystemObject
  System.CollectionsCollectionBase
    Aspose.CellsWorksheetCollection

Namespace: Aspose.Cells
Assembly: Aspose.Cells (in Aspose.Cells.dll) Version: 19.11.0.0 (19.11)
Syntax
public class WorksheetCollection : CollectionBase

The WorksheetCollection type exposes the following members.

Properties
  NameDescription
Public propertyActiveSheetIndex
Represents the index of active worksheet when the spreadsheet is opened.
Public propertyCode exampleBuiltInDocumentProperties
Returns a DocumentProperties collection that represents all the built-in document properties of the spreadsheet.
Public propertyCapacity
Gets or sets the number of elements that the CollectionBase can contain.
(Inherited from CollectionBase.)
Public propertyCount
Gets the number of elements contained in the CollectionBase instance. This property cannot be overridden.
(Inherited from CollectionBase.)
Public propertyCode exampleCustomDocumentProperties
Returns a DocumentProperties collection that represents all the custom document properties of the spreadsheet.
Public propertyDxfs
Gets the master differential formatting records.
Public propertyExternalLinks
Represents external links in a workbook.
Protected propertyInnerList
Gets an ArrayList containing the list of elements in the CollectionBase instance.
(Inherited from CollectionBase.)
Public propertyIsRefreshAllConnections
Indicates whether refresh all connections on opening file in MS Excel.
Public propertyItemInt32
Gets the Worksheet element at the specified index.
Public propertyItemString
Gets the Worksheet element with the specified name.
Protected propertyList
Gets an IList containing the list of elements in the CollectionBase instance.
(Inherited from CollectionBase.)
Public propertyNames
Gets the collection of all the Name objects in the spreadsheet.
Public propertyOleSize
Gets and Sets displayed size when Workbook file is used as an Ole object.
Public propertyRevisionLogs
Represents revision logs.
Public propertyTableStyles
Gets TableStyles object.
Public propertyThreadedCommentAuthors
Gets the list of threaded comment authors.
Public propertyWebExtensions
Gets the list of task panes.
Public propertyWebExtensionTaskPanes
Gets the list of task panes.
Public propertyXmlMaps
Gets and sets the XML maps in the workbook.
Methods
  NameDescription
Public methodAdd
Adds a worksheet to the collection.
Public methodAdd(String)
Adds a worksheet to the collection.
Public methodCode exampleAdd(SheetType)
Adds a worksheet to the collection.
Public methodAddCopy(Int32)
Adds a worksheet to the collection and copies data from an existed worksheet.
Public methodAddCopy(String)
Adds a worksheet to the collection and copies data from an existed worksheet.
Public methodClear
Clear all worksheets.
Public methodClearPivottables
Clears pivot tables from the spreadsheet.
Public methodCreateRange
Creates a Range object from an address of the range.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the CollectionBase instance.
(Inherited from CollectionBase.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetNamedRanges
Gets all pre-defined named ranges in the spreadsheet.
Public methodGetNamedRangesAndTables
Gets all pre-defined named ranges in the spreadsheet.
Public methodGetRangeByName
Gets Range object by pre-defined name.
Public methodGetSheetByCodeName
Gets the worksheet by the code name.
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodInsert(Int32, SheetType)
Insert a worksheet.
Public methodInsert(Int32, SheetType, String)
Insert a worksheet.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnClear
Performs additional custom processes when clearing the contents of the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnClearComplete
Performs additional custom processes after clearing the contents of the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnInsert
Performs additional custom processes before inserting a new element into the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnInsertComplete
Performs additional custom processes after inserting a new element into the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnRemove
Performs additional custom processes when removing an element from the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnRemoveComplete
Performs additional custom processes after removing an element from the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnSet
Performs additional custom processes before setting a value in the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnSetComplete
Performs additional custom processes after setting a value in the CollectionBase instance.
(Inherited from CollectionBase.)
Protected methodOnValidate
Performs additional custom processes when validating a value.
(Inherited from CollectionBase.)
Public methodRegisterAddInFunction(Int32, String)
Adds addin function into the workbook
Public methodRegisterAddInFunction(String, String, Boolean)
Adds addin function into the workbook
Public methodRemoveAt(Int32)
Removes the element at a specified index.
Public methodRemoveAt(String)
Removes the element at a specified name.
Public methodSetOleSize
Sets displayed size when Workbook file is used as an Ole object.
Public methodSortNames
Sorts the defined names.
Public methodSwapSheet
Swaps the two sheets.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
[C#]

Workbook workbook = new Workbook();

WorksheetCollection sheets = workbook.Worksheets;

//Add a worksheet
sheets.Add();

//Change the name of a worksheet
sheets[0].Name = "First Sheet";

//Set the active sheet to the second worksheet
sheets.SetActiveSheet(1);


[Visual Basic]

Dim excel as Workbook = new Workbook()

Dim sheets as WorksheetCollection = excel.Worksheets

'Add a worksheet
sheets.Add()

'Change the name of a worksheet
sheets(0).Name = "First Sheet"

'Set the active sheet to the second worksheet
sheets.SetActiveSheet(1)
See Also