New to Telerik Document ProcessingStart a free 30-day trial

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:

C#
public class SheetCollection : IEnumerable<Sheet>, IEnumerable

Inheritance: objectSheetCollection

Implements: IEnumerableIEnumerable<Sheet>

Events

Raised when the active sheet reference changes, allowing UI to switch displayed content.

C#
public event EventHandler ActiveSheetChanged

Raised when the active sheet's index changes, allowing UI to update tab selection.

C#
public event EventHandler ActiveSheetIndexChanged

Raised after a sheet operation completes (add, remove, hide, unhide, move, clear), providing change details.

C#
public event EventHandler<SheetCollectionChangedEventArgs> Changed

Methods

Creates a new sheet of the specified type with a generated unique name and appends it to the collection.

C#
public Sheet Add(SheetType type)
Parameters:typeSheetType

The type of sheet.

Returns:

Sheet

The newly created sheet.

Checks whether the specified sheet exists in this collection.

C#
public bool Contains(Sheet sheet)
Parameters:sheetSheet

The sheet.

Returns:

bool

The value indicating whether the sheet is contained in the collection.

Checks whether a sheet with the specified name exists in the collection, using case-insensitive comparison.

C#
public bool Contains(string sheetName)
Parameters:sheetNamestring

The name of the sheet.

Returns:

bool

The value indicating whether a sheet with the specified name is contained in the collection.

Retrieves the sheet with the specified name using case-insensitive comparison, or null if not found.

C#
public Sheet GetByName(string sheetName)
Parameters:sheetNamestring

The name of the sheet.

Returns:

Sheet

The sheet.

Returns an enumerator for iterating through all sheets in order.

C#
public IEnumerator<Sheet> GetEnumerator()
Returns:

IEnumerator<Sheet>

A IEnumerator<T> that can be used to iterate through the collection.

Implements: IEnumerable<Sheet>.GetEnumerator()

Hides the currently active sheet, ensuring at least one visible sheet remains.

C#
public void Hide()

Hides the sheet at the specified index, ensuring at least one visible sheet remains.

C#
public void Hide(int index)
Parameters:indexint

The index.

Hides the specified sheet, ensuring at least one visible sheet remains.

C#
public void Hide(Sheet sheet)
Parameters:sheetSheet

The sheet.

Searches for the specified sheet and returns its zero-based index, or -1 if not found.

C#
public int IndexOf(Sheet sheet)
Parameters:sheetSheet

The sheet.

Returns:

int

The index of the sheet.

Searches for a sheet with the specified name using case-insensitive comparison and returns its zero-based index, or -1 if not found.

C#
public int IndexOf(string sheetName)
Parameters:sheetNamestring

The name of the sheet.

Returns:

int

The index of the sheet.

Creates a new sheet of the specified type with a generated unique name and inserts it at the specified index.

C#
public Sheet Insert(int index, SheetType type)
Parameters:indexint

The index.

typeSheetType

The type.

Returns:

Sheet

The newly created sheet.

Creates a new sheet of the specified type with a generated unique name and inserts it at the active sheet's index.

C#
public Sheet Insert(SheetType type)
Parameters:typeSheetType

The type.

Returns:

Sheet

The newly created sheet.

Relocates a contiguous range of sheets from the source index to the destination index, shifting other sheets as needed.

C#
public void Move(int fromIndex, int itemCount, int toIndex)
Parameters:fromIndexint

From index.

itemCountint

The item count.

toIndexint

To index.

Raises the ActiveSheetChanged event, notifying subscribers of sheet change.

C#
protected virtual void OnActiveSheetChanged()

Raises the ActiveSheetIndexChanged event, notifying subscribers of index change.

C#
protected virtual void OnActiveSheetIndexChanged()

Raises the Changed event, notifying subscribers of completed collection modification.

C#
protected virtual void OnChanged(SheetCollectionChangedEventArgs args)
Parameters:argsSheetCollectionChangedEventArgs

The SheetCollectionChangedEventArgs instance containing the event data.

Removes the currently active sheet from the collection, ensuring at least one visible sheet remains.

C#
public void Remove()

Removes the specified sheet from the collection and returns true if found, false otherwise.

C#
public bool Remove(Sheet sheet)
Parameters:sheetSheet

The sheet.

Returns:

bool

The value indicating whether the specified sheet was found.

Removes the sheet with the specified name and returns true if found, false otherwise.

C#
public bool Remove(string sheetName)
Parameters:sheetNamestring

The name of the sheet.

Returns:

bool

The value indicating whether a sheet with a specified name was found.

Removes the sheet at the specified index, ensuring at least one visible sheet remains.

C#
public void RemoveAt(int index)
Parameters:indexint

The index.

Makes the sheet at the specified index visible and sets it as the active sheet.

C#
public void Unhide(int index)
Parameters:indexint

The index.

Makes the specified sheet visible and sets it as the active sheet.

C#
public void Unhide(Sheet sheet)
Parameters:sheetSheet

The sheet.

Properties

Currently selected sheet displayed to the user; must be a sheet from this collection.

C#
public Sheet ActiveSheet { get; set; }
Property Value:

The active sheet.

Zero-based index of the active sheet, or -1 if no sheets exist; setting updates both index and ActiveSheet.

C#
public int ActiveSheetIndex { get; set; }
Property Value:

The index of the active sheet.

Total number of sheets in the collection, including hidden and very hidden sheets.

C#
public int Count { get; }
Property Value:

The count of the sheets.

Retrieves the sheet at the specified zero-based index.

C#
public Sheet this[int index] { get; }
Parameters:indexintProperty Value:

The sheet.

Retrieves the sheet with the specified name, using case-insensitive comparison.

C#
public Sheet this[string sheetName] { get; }
Parameters:sheetNamestringProperty Value:

The sheet.

Workbook that owns this collection, providing the context for sheet operations.

C#
public Workbook Workbook { get; }
Property Value:

The workbook.