Skip to main content
A newer version of this page is available. .

How to: Create a New Workbook

  • 2 minutes to read

To work with a spreadsheet document programmatically, create an instance of the Workbook class. This is a root object that serves as the starting point for using a non-visual spreadsheet engine.

Important

The Workbook class in defined in the DevExpress.Docs.v17.2.dll assembly. Make sure you added a reference for this library to your project before using the workbook functionality. Note that use of this library in production code requires a license to the DevExpress Document Server or DevExpress Universal Subscription. Refer to the DevExpress Subscription page for pricing information.

By default, a new workbook contains one empty worksheet (“Sheet1”). You can add and delete worksheets, if required. The same workbook is also created when you call the Workbook.CreateNewDocument method.

To load an existing spreadsheet document to a workbook, call the Workbook.LoadDocument method. To save a workbook to a file, use the Workbook.SaveDocument method. See the How to: Load a Document to a Workbook and How to: Save a Document to a File examples.

// Add a reference to the DevExpress.Docs.dll assembly.
using DevExpress.Spreadsheet;
// ...

// Create a new Workbook object.
Workbook workbook = new Workbook();

Note

Resolving Performance Issues To improve performance while applying multiple modifications to a document, wrap your code in the Workbook.BeginUpdate-Workbook.EndUpdate method calls.

When you finish working with the Workbook, you are advised to call the Workbook.Dispose method to release all the resources used by the object. This will allow you to avoid memory leaks and speed up system performance. You can also operate with the Workbook instance within the using statement (Using block in Visual Basic).