Class
Workbook

The top-level container for an Excel-compatible spreadsheet document, managing sheets, styles, history, and document-wide settings.

Definition

Namespace:Telerik.Windows.Documents.Spreadsheet.Model

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Syntax:

cs-api-definition
public class Workbook : NotifyPropertyChangedBase, INotifyPropertyChanged, IDisposable

Inheritance: objectNotifyPropertyChangedBaseWorkbook

Implements: IDisposableINotifyPropertyChanged

Inherited Members NotifyPropertyChangedBase.OnPropertyChanged(string)NotifyPropertyChangedBase.OnPropertyChanged(PropertyChangedEventArgs)NotifyPropertyChangedBase.PropertyChanged

Constructors

Workbook()

Initializes a new Workbook with default settings and an empty sheet collection.

Declaration

cs-api-definition
public Workbook()

Properties

ActiveSheet

Gets or sets the sheet currently selected for viewing and editing.

Declaration

cs-api-definition
public Sheet ActiveSheet { get; set; }

Property Value

Sheet

The active sheet.

ActiveTabIndex

Gets or sets the zero-based index of the currently selected sheet tab.

Declaration

cs-api-definition
public int ActiveTabIndex { get; set; }

Property Value

int

The index of the active tab.

ActiveWorksheet

Gets or sets the data worksheet currently selected, returning null if the active sheet is not a worksheet.

Declaration

cs-api-definition
public Worksheet ActiveWorksheet { get; set; }

Property Value

Worksheet

The active worksheet.

DocumentInfo

Gets or sets the document metadata such as title, author, subject, and keywords.

Declaration

cs-api-definition
public DocumentInfo DocumentInfo { get; set; }

Property Value

DocumentInfo

The document information.

History

Gets the undo/redo history for tracking and reversing user modifications.

Declaration

cs-api-definition
public WorkbookHistory History { get; }

Property Value

WorkbookHistory

The history for this workbook.

IsLayoutUpdateSuspended

Gets whether layout recalculation is temporarily disabled for batch modifications.

Declaration

cs-api-definition
public bool IsLayoutUpdateSuspended { get; }

Property Value

bool

The value indicating whether the layout update is suspended.

IsProtected

Gets whether the workbook structure is password-protected, preventing sheet additions, deletions, or reordering.

Declaration

cs-api-definition
public bool IsProtected { get; }

Property Value

bool

The is protected.

Name

Gets or sets the document name, typically displayed in the application title bar.

Declaration

cs-api-definition
public string Name { get; set; }

Property Value

string

The name of the workbook.

Names

Gets the workbook-scoped named ranges and formulas accessible across all sheets.

Declaration

cs-api-definition
public NameCollection Names { get; }

Property Value

NameCollection

The collection of defined names of the workbook.

Sheets

Gets all sheets in the workbook, including worksheets and chart sheets.

Declaration

cs-api-definition
public SheetCollection Sheets { get; }

Property Value

SheetCollection

The sheets of the workbook.

Styles

Gets the named cell styles that can be applied to cells throughout the workbook.

Declaration

cs-api-definition
public CellStyleCollection Styles { get; }

Property Value

CellStyleCollection

The collection of styles for this workbook.

Theme

Gets or sets the color scheme and font theme applied to themable elements throughout the workbook.

Declaration

cs-api-definition
public DocumentTheme Theme { get; set; }

Property Value

DocumentTheme

The workbook theme.

WorkbookContentChangedInterval

Gets or sets the throttling interval for WorkbookContentChanged event notifications to reduce event frequency during rapid edits.

Declaration

cs-api-definition
public TimeSpan WorkbookContentChangedInterval { get; set; }

Property Value

TimeSpan

The interval on which the workbook content changes.

Worksheets

Gets the data worksheets, excluding chart sheets and other sheet types.

Declaration

cs-api-definition
public WorksheetCollection Worksheets { get; }

Property Value

WorksheetCollection

The worksheets of the workbook.

Methods

CallOnWorkbookContentChanged()

Schedules the WorkbookContentChanged event to fire after the throttling interval.

Declaration

cs-api-definition
protected void CallOnWorkbookContentChanged()

Dispose()

Releases all resources used by the workbook.

Declaration

cs-api-definition
public void Dispose()

Implements IDisposable.Dispose()

Dispose(bool)

Releases resources, optionally disposing managed objects.

Declaration

cs-api-definition
protected virtual void Dispose(bool cleanUpManagedResources)

Parameters

cleanUpManagedResources

bool

The clean up managed resources.

Find(FindOptions)

Searches for the next occurrence matching the specified criteria and returns its location, or null if not found.

Declaration

cs-api-definition
public FindResult Find(FindOptions findOptions)

Parameters

findOptions

FindOptions

The find options.

Returns

FindResult

The find results.

FindAll(FindOptions)

Searches for all occurrences matching the specified criteria and returns their locations.

Declaration

cs-api-definition
public IEnumerable<FindResult> FindAll(FindOptions findOptions)

Parameters

findOptions

FindOptions

The find options.

Returns

IEnumerable<FindResult>

The find results.

OnActiveSheetChanged()

Called when the active sheet is changed.

Declaration

cs-api-definition
protected virtual void OnActiveSheetChanged()

OnCommandError(CommandErrorEventArgs)

Raises the event.

Declaration

cs-api-definition
protected virtual void OnCommandError(CommandErrorEventArgs args)

Parameters

args

CommandErrorEventArgs

The CommandErrorEventArgs instance containing the event data.

OnCommandExecuted(CommandExecutedEventArgs)

Raises the event, recording the command in history if undoable.

Declaration

cs-api-definition
protected virtual void OnCommandExecuted(CommandExecutedEventArgs args)

Parameters

args

CommandExecutedEventArgs

The CommandExecutedEventArgs instance containing the event data.

OnCommandExecuting(CommandExecutingEventArgs)

Raises the event, iterating handlers until one sets Canceled.

Declaration

cs-api-definition
protected virtual void OnCommandExecuting(CommandExecutingEventArgs args)

Parameters

args

CommandExecutingEventArgs

The CommandExecutingEventArgs instance containing the event data.

OnIsProtectedChanged()

Called when [is protected changed].

Declaration

cs-api-definition
protected virtual void OnIsProtectedChanged()

OnThemeChanged()

Called when [theme changed].

Declaration

cs-api-definition
protected virtual void OnThemeChanged()

OnWorkbookContentChanged()

Called when [workbook content changed].

Declaration

cs-api-definition
protected virtual void OnWorkbookContentChanged()

Protect(string)

Protects the workbook structure with a password, preventing sheet additions, deletions, and reordering.

Declaration

cs-api-definition
public void Protect(string password)

Parameters

password

string

The password.

Replace(ReplaceOptions)

Replaces the next occurrence in the active worksheet matching the specified criteria and returns whether a replacement was made.

Declaration

cs-api-definition
public bool Replace(ReplaceOptions replaceOptions)

Parameters

replaceOptions

ReplaceOptions

The replace options.

Returns

bool

The value indicating whether a value was found to replace.

ReplaceAll(ReplaceOptions)

Replaces all occurrences matching the specified criteria and returns the count of replacements made.

Declaration

cs-api-definition
public int ReplaceAll(ReplaceOptions replaceOptions)

Parameters

replaceOptions

ReplaceOptions

The replace options.

Returns

int

The number of replacements made.

ResumeLayoutUpdate()

Re-enables layout recalculation and triggers an update if modifications occurred while suspended.

Declaration

cs-api-definition
public void ResumeLayoutUpdate()

SuspendLayoutUpdate()

Temporarily disables layout recalculation to improve performance during batch modifications; call ResumeLayoutUpdate when complete.

Declaration

cs-api-definition
public void SuspendLayoutUpdate()

Unprotect(string)

Removes workbook structure protection using the specified password and returns whether the password was correct.

Declaration

cs-api-definition
public bool Unprotect(string password)

Parameters

password

string

The password.

Returns

bool

Events

ActiveSheetChanged

Raised when the user selects a different sheet.

Declaration

cs-api-definition
public event EventHandler ActiveSheetChanged

Event Value

EventHandler

CommandError

Raised when a command encounters an error during execution.

Declaration

cs-api-definition
public event EventHandler<CommandErrorEventArgs> CommandError

Event Value

EventHandler<CommandErrorEventArgs>

CommandExecuted

Raised after a command successfully completes execution.

Declaration

cs-api-definition
public event EventHandler<CommandExecutedEventArgs> CommandExecuted

Event Value

EventHandler<CommandExecutedEventArgs>

CommandExecuting

Raised before a command executes, allowing cancellation via the event args.

Declaration

cs-api-definition
public event EventHandler<CommandExecutingEventArgs> CommandExecuting

Event Value

EventHandler<CommandExecutingEventArgs>

IsProtectedChanged

Raised when the workbook's protection state changes between protected and unprotected.

Declaration

cs-api-definition
public event EventHandler IsProtectedChanged

Event Value

EventHandler

NameChanged

Raised when the workbook's name property changes.

Declaration

cs-api-definition
public event EventHandler NameChanged

Event Value

EventHandler

ThemeChanged

Raised when the workbook's theme is changed.

Declaration

cs-api-definition
public event EventHandler ThemeChanged

Event Value

EventHandler

WorkbookContentChanged

Raised when any content changes, throttled according to WorkbookContentChangedInterval.

Declaration

cs-api-definition
public event EventHandler WorkbookContentChanged

Event Value

EventHandler