WorksheetCollection Class

Encapsulates a collection of Worksheet objects.
Inheritance Hierarchy

Namespace:  Aspose.Cells
Assembly:  Aspose.Cells (in Aspose.Cells.dll) Version: 20.1.0.0 (20.1)
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 (Inherited from CollectionBase.)
Public propertyCount (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 (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 (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 (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetEnumerator (Inherited from CollectionBase.)
Public methodGetHashCode (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 (Inherited from Object.)
Public methodInsert(Int32, SheetType)
Insert a worksheet.
Public methodInsert(Int32, SheetType, String)
Insert a worksheet.
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnClear (Inherited from CollectionBase.)
Protected methodOnClearComplete (Inherited from CollectionBase.)
Protected methodOnInsert (Inherited from CollectionBase.)
Protected methodOnInsertComplete (Inherited from CollectionBase.)
Protected methodOnRemove (Inherited from CollectionBase.)
Protected methodOnRemoveComplete (Inherited from CollectionBase.)
Protected methodOnSet (Inherited from CollectionBase.)
Protected methodOnSetComplete (Inherited from CollectionBase.)
Protected methodOnValidate (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 (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