ClassSheetCollection
Ordered collection of sheets in a workbook, managing sheet creation, insertion, removal, visibility, and active sheet tracking with validation and event notifications.
Definition
Namespace:Telerik.Windows.Documents.Spreadsheet.Model
Assembly:Telerik.Windows.Documents.Spreadsheet.dll
Syntax:
public class SheetCollection : IEnumerable<Sheet>, IEnumerable
Inheritance: objectSheetCollection
Implements:
Properties
ActiveSheet
Currently selected sheet displayed to the user; must be a sheet from this collection.
Declaration
public Sheet ActiveSheet { get; set; }
Property Value
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
The index of the active sheet.
Count
Total number of sheets in the collection, including hidden and very hidden sheets.
Workbook
Workbook that owns this collection, providing the context for sheet operations.
Declaration
public Workbook Workbook { get; }
Property Value
The workbook.
this[int]
Retrieves the sheet at the specified zero-based index.
this[string]
Retrieves the sheet with the specified name, using case-insensitive comparison.
Methods
Add(SheetType)
Creates a new sheet of the specified type with a generated unique name and appends it to the collection.
Contains(Sheet)
Checks whether the specified sheet exists in this collection.
Contains(string)
Checks whether a sheet with the specified name exists in the collection, using case-insensitive comparison.
GetByName(string)
Retrieves the sheet with the specified name using case-insensitive comparison, or null if not found.
GetEnumerator()
Returns an enumerator for iterating through all sheets in order.
Declaration
public IEnumerator<Sheet> GetEnumerator()
Returns
A 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(Sheet)
Hides the specified sheet, ensuring at least one visible sheet remains.
Hide(int)
Hides the sheet at the specified index, ensuring at least one visible sheet remains.
IndexOf(Sheet)
Searches for the specified sheet and returns its zero-based index, or -1 if not found.
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.
Insert(SheetType)
Creates a new sheet of the specified type with a generated unique name and inserts it at the active sheet's index.
Insert(int, SheetType)
Creates a new sheet of the specified type with a generated unique name and inserts it at the specified index.
Move(int, int, int)
Relocates a contiguous range of sheets from the source index to the destination index, shifting other sheets as needed.
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
args
SheetCollectionChangedEventArgs
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(Sheet)
Removes the specified sheet from the collection and returns true if found, false otherwise.
Remove(string)
Removes the sheet with the specified name and returns true if found, false otherwise.
RemoveAt(int)
Removes the sheet at the specified index, ensuring at least one visible sheet remains.
Unhide(Sheet)
Makes the specified sheet visible and sets it as the active sheet.
Unhide(int)
Makes the sheet at the specified index visible and sets it as the active sheet.
Events
ActiveSheetChanged
Raised when the active sheet reference changes, allowing UI to switch displayed content.
ActiveSheetIndexChanged
Raised when the active sheet's index changes, allowing UI to update tab selection.
Declaration
public event EventHandler ActiveSheetIndexChanged
Event Value
Changed
Raised after a sheet operation completes (add, remove, hide, unhide, move, clear), providing change details.
Declaration
public event EventHandler<SheetCollectionChangedEventArgs> Changed
Event Value