Class SheetCollection
Ordered collection of sheets in a workbook, managing sheet creation, insertion, removal, visibility, and active sheet tracking with validation and event notifications.
Inheritance
Inherited Members
Namespace: Telerik.Windows.Documents.Spreadsheet.Model
Assembly: Telerik.Windows.Documents.Spreadsheet.dll
Syntax
public class SheetCollection : IEnumerable<Sheet>, IEnumerable
Properties
ActiveSheet
Currently selected sheet displayed to the user; must be a sheet from this collection.
Declaration
public Sheet ActiveSheet { get; set; }
Property Value
|
Sheet
The active sheet. |
ActiveSheetIndex
Zero-based index of the active sheet, or -1 if no sheets exist; setting updates both index and ActiveSheet.
Declaration
public int ActiveSheetIndex { get; set; }
Property Value
|
System.Int32
The index of the active sheet. |
Count
Total number of sheets in the collection, including hidden and very hidden sheets.
Declaration
public int Count { get; }
Property Value
|
System.Int32
The count of the sheets. |
Item[Int32]
Retrieves the sheet at the specified zero-based index.
Declaration
public Sheet this[int index] { get; }
Parameters
|
System.Int32
index
|
Property Value
|
Sheet
The sheet. |
Item[String]
Retrieves the sheet with the specified name, using case-insensitive comparison.
Declaration
public Sheet this[string sheetName] { get; }
Parameters
|
System.String
sheetName
|
Property Value
|
Sheet
The sheet. |
Workbook
Workbook that owns this collection, providing the context for sheet operations.
Declaration
public Workbook Workbook { get; }
Property Value
|
Workbook
The workbook. |
Methods
Add(SheetType)
Creates a new sheet of the specified type with a generated unique name and appends it to the collection.
Declaration
public Sheet Add(SheetType type)
Parameters
|
SheetType
type
The type of sheet. |
Returns
|
Sheet
The newly created sheet. |
Contains(String)
Checks whether a sheet with the specified name exists in the collection, using case-insensitive comparison.
Declaration
public bool Contains(string sheetName)
Parameters
|
System.String
sheetName
The name of the sheet. |
Returns
|
System.Boolean
The value indicating whether a sheet with the specified name is contained in the collection. |
Contains(Sheet)
Checks whether the specified sheet exists in this collection.
Declaration
public bool Contains(Sheet sheet)
Parameters
|
Sheet
sheet
The sheet. |
Returns
|
System.Boolean
The value indicating whether the sheet is contained in the collection. |
GetByName(String)
Retrieves the sheet with the specified name using case-insensitive comparison, or null if not found.
Declaration
public Sheet GetByName(string sheetName)
Parameters
|
System.String
sheetName
The name of the sheet. |
Returns
|
Sheet
The sheet. |
GetEnumerator()
Returns an enumerator for iterating through all sheets in order.
Declaration
public IEnumerator<Sheet> GetEnumerator()
Returns
|
System.Collections.Generic.IEnumerator<Sheet>
A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
Implements
Hide()
Hides the currently active sheet, ensuring at least one visible sheet remains.
Declaration
public void Hide()
Hide(Int32)
Hides the sheet at the specified index, ensuring at least one visible sheet remains.
Declaration
public void Hide(int index)
Parameters
|
System.Int32
index
The index. |
Hide(Sheet)
Hides the specified sheet, ensuring at least one visible sheet remains.
Declaration
public void Hide(Sheet sheet)
Parameters
|
Sheet
sheet
The sheet. |
IndexOf(String)
Searches for a sheet with the specified name using case-insensitive comparison and returns its zero-based index, or -1 if not found.
Declaration
public int IndexOf(string sheetName)
Parameters
|
System.String
sheetName
The name of the sheet. |
Returns
|
System.Int32
The index of the sheet. |
IndexOf(Sheet)
Searches for the specified sheet and returns its zero-based index, or -1 if not found.
Declaration
public int IndexOf(Sheet sheet)
Parameters
|
Sheet
sheet
The sheet. |
Returns
|
System.Int32
The index of the sheet. |
Insert(Int32, SheetType)
Creates a new sheet of the specified type with a generated unique name and inserts it at the specified index.
Declaration
public Sheet Insert(int index, SheetType type)
Parameters
|
System.Int32
index
The index. |
|
SheetType
type
The type. |
Returns
|
Sheet
The newly created sheet. |
Insert(SheetType)
Creates a new sheet of the specified type with a generated unique name and inserts it at the active sheet's index.
Declaration
public Sheet Insert(SheetType type)
Parameters
|
SheetType
type
The type. |
Returns
|
Sheet
The newly created sheet. |
Move(Int32, Int32, Int32)
Relocates a contiguous range of sheets from the source index to the destination index, shifting other sheets as needed.
Declaration
public void Move(int fromIndex, int itemCount, int toIndex)
Parameters
|
System.Int32
fromIndex
From index. |
|
System.Int32
itemCount
The item count. |
|
System.Int32
toIndex
To index. |
OnActiveSheetChanged()
Raises the ActiveSheetChanged event, notifying subscribers of sheet change.
Declaration
protected virtual void OnActiveSheetChanged()
OnActiveSheetIndexChanged()
Raises the ActiveSheetIndexChanged event, notifying subscribers of index change.
Declaration
protected virtual void OnActiveSheetIndexChanged()
OnChanged(SheetCollectionChangedEventArgs)
Raises the Changed event, notifying subscribers of completed collection modification.
Declaration
protected virtual void OnChanged(SheetCollectionChangedEventArgs args)
Parameters
|
SheetCollectionChangedEventArgs
args
The SheetCollectionChangedEventArgs instance containing the event data. |
Remove()
Removes the currently active sheet from the collection, ensuring at least one visible sheet remains.
Declaration
public void Remove()
Remove(String)
Removes the sheet with the specified name and returns true if found, false otherwise.
Declaration
public bool Remove(string sheetName)
Parameters
|
System.String
sheetName
The name of the sheet. |
Returns
|
System.Boolean
The value indicating whether a sheet with a specified name was found. |
Remove(Sheet)
Removes the specified sheet from the collection and returns true if found, false otherwise.
Declaration
public bool Remove(Sheet sheet)
Parameters
|
Sheet
sheet
The sheet. |
Returns
|
System.Boolean
The value indicating whether the specified sheet was found. |
RemoveAt(Int32)
Removes the sheet at the specified index, ensuring at least one visible sheet remains.
Declaration
public void RemoveAt(int index)
Parameters
|
System.Int32
index
The index. |
Unhide(Int32)
Makes the sheet at the specified index visible and sets it as the active sheet.
Declaration
public void Unhide(int index)
Parameters
|
System.Int32
index
The index. |
Unhide(Sheet)
Makes the specified sheet visible and sets it as the active sheet.
Declaration
public void Unhide(Sheet sheet)
Parameters
|
Sheet
sheet
The sheet. |
Events
ActiveSheetChanged
Raised when the active sheet reference changes, allowing UI to switch displayed content.
Declaration
public event EventHandler ActiveSheetChanged
Event Type
|
System.EventHandler
|
ActiveSheetIndexChanged
Raised when the active sheet's index changes, allowing UI to update tab selection.
Declaration
public event EventHandler ActiveSheetIndexChanged
Event Type
|
System.EventHandler
|
Changed
Raised after a sheet operation completes (add, remove, hide, unhide, move, clear), providing change details.
Declaration
public event EventHandler<SheetCollectionChangedEventArgs> Changed
Event Type
|
System.EventHandler<SheetCollectionChangedEventArgs>
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns a non-generic enumerator for iterating through all sheets in order.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
|
System.Collections.IEnumerator
An System.Collections.IEnumerator object that can be used to iterate through the collection. |