wpf-16174-controls-and-libraries-spreadsheet-spreadsheet-document-workbook.md
Use the SpreadsheetControl.Document property to obtain an IWorkbook object that allows you to modify a workbook loaded in the Spreadsheet control.
using DevExpress.Spreadsheet;
// ...
// Access a workbook.
IWorkbook workbook = spreadsheetControl.Document;
Imports DevExpress.Spreadsheet
' ...
' Access a workbook.
Dim workbook As IWorkbook = spreadsheetControl.Document
A workbook consists of one or more worksheets stored in the IWorkbook.Worksheets collection. When you create a SpreadsheetControl instance, it contains a workbook with an empty worksheet. Use the WorksheetCollection members to add a new worksheet, remove an existing worksheet, rename a worksheet, select an active worksheet, and so on.
A workbook can also contain chart sheets that display only a chart. Use the IWorkbook.ChartSheets property to access and modify the chart sheet collection.
The IWorkbook.Sheets collection stores all sheets (worksheets and chart sheets) in a workbook. Use this collection to obtain a sheet of any type.
The IWorkbook.DefinedNames collection includes global defined names that are available in any of the current workbook’s worksheets.
You can include functions in your formulas to perform calculations. Use the IWorkbook.Functions property to access the WorkbookFunctions object that stores all built-in functions and allows you to override any function via the WorkbookFunctions.OverrideFunction method.
See how to use functions in formulas.
You can also create a custom function. To add a custom function to a workbook, define a class that implements the ICustomFunction interface and add its instance to the IWorkbook.CustomFunctions or IWorkbook.GlobalCustomFunctions collection.
See how to create a custom function.
Note
Custom functions are not saved. To replace custom function definitions with calculated values when a workbook is saved, set the SpreadsheetExportOptions.CustomFunctionExportMode option to CalculatedValue.
A workbook contains a collection of styles used to format cell appearance. Use the IWorkbook.Styles property to access and modify this collection.
See how to add new cell styles or modify the existing styles.
The IWorkbook.TableStyles collection stores styles you can apply to tables and pivot tables. You can select a built-in style or create a custom style.
See how to apply a style to a table
See how to apply a style to a pivot table.
You can embed arbitrary XML data in workbooks in Excel file formats. This data is named custom XML parts and stored in the IWorkbook.CustomXmlParts collection. Use the collection’s members to create and modify custom XML parts.
The following table lists operations you can perform on a workbook. The commands listed below are also available in the Ribbon UI.
|
Task
|
API Members/Examples
| | --- | --- | |
Create a new workbook
|
SpreadsheetControl.CreateNewDocument
ISpreadsheetComponent.CreateNewDocument
| |
Load a workbook
|
SpreadsheetControl.LoadDocument
ISpreadsheetComponent.LoadDocument
How to: Load a Document into SpreadsheetControl
| |
Save a workbook
|
SpreadsheetControl.SaveDocument
ISpreadsheetComponent.SaveDocument
SpreadsheetControl.ExportToHtml
SpreadsheetControl.ExportToPdf
How to: Save a Document to a File
How to: Export a Workbook to PDF
How to: Export a Document to HTML
| |
Protect a workbook
|
| |
Encrypt a workbook
|
SpreadsheetControl.SaveDocument
ISpreadsheetComponent.SaveDocument
| |
Print a workbook
|
SpreadsheetControl.ShowPrintPreview
SpreadsheetControl.ShowPrintDialog
| |
Undo or redo an action
|
| |
View and edit document properties
|
How to: Specify Document Properties
|
Use the SpreadsheetControl.Options or SpreadsheetControl.Document.Options property to get access to various document options. They include:
|
SpreadsheetControlOptions.Import,
|
Specifies options used to import documents in different file formats.
| |
SpreadsheetControlOptions.Export,
|
Specifies options used to export documents to different file formats.
| |
SpreadsheetControlOptions.Save,
|
Defines the file name and file format used when a workbook is saved.
| |
SpreadsheetControlOptions.Export,
DocumentOptions.DocumentCapabilities
|
Allows you to disable the following document features: Formulas, Charts, Pictures, Shapes, Sparklines, and Undo.
| |
SpreadsheetControlOptions.Cells,
|
Specifies options for worksheet cells.
| |
SpreadsheetControlOptions.Copy,
|
Contains options that allow you to control copy operations.
| |
SpreadsheetControlOptions.Clipboard,
|
Contains options for clipboard operations.
| |
SpreadsheetControlOptions.RaiseEventsOnModificationsViaAPI
|
Enables you to raise the SpreadsheetControl’s events for changes performed via the API.
| |
SpreadsheetControlOptions.Culture,
|
Provides culture-specific settings.
| |
DocumentOptions.CalculationMode
|
Specifies the calculation mode for the Spreadsheet control.
| |
SpreadsheetControlOptions.CalculationEngineType,
DocumentOptions.CalculationEngineType
|
Specifies the computational model used to perform calculations in a workbook.
| |
SpreadsheetControlOptions.RealTimeData,
|
Provides access to options for real-time data (RTD) function calculation.
| |
|
Allows you to specify the UseStrongPasswordVerifier and SpinCount password protection options.
| |
SpreadsheetControlOptions.DataSourceLoading,
DocumentOptions.DataSourceLoading
|
Provides access to CustomAssemblyBehavior option that specifies whether to load a custom assembly with the Entity Framework data context during mail merge.
| |
SpreadsheetControlOptions.Compatibility
|
Provides access to the following compatibility settings:
SpreadsheetCompatibilityOptions.EnableLegacyLayoutEngine - allows you to turn off the new layout engine and its features.
SpreadsheetCompatibilityOptions.EnableLegacyPdfExport - enables the legacy PDF export engine.
SpreadsheetCompatibilityOptions.EnableLegacyPrintLayout - disables print layout enhancements.
| |
|
Specifies whether to apply the WorksheetView.Zoom setting to all worksheet views or the current view only.
|
Other workbook settings are available from the IWorkbook.DocumentSettings property.
|
|
Provides access to formula calculation options.
| |
DocumentSettings.R1C1ReferenceStyle
|
Specifies whether a workbook should use the R1C1 reference style.
| |
|
Provides access to document encryption options.
| |
DocumentSettings.ShowPivotTableFieldList
|
Specifies whether to show Field List for pivot tables in a workbook.
|
The WorkbookExtensions class defines extension methods for the IWorkbook object.
|
|
Appends all worksheets from the specified workbooks to the current workbook.
See how to merge multiple workbooks into one document.
| |
|
Creates a workbook’s copy.
|
To enable workbook extensions, add a reference to the DevExpress.Docs.v25.2.dll library and import the DevExpress.Spreadsheet namespace into your code with a using directive ( Imports in Visual Basic).
Note
You need an active license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use these extension methods in production code.