Skip to main content

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 is defined in the DevExpress.Docs.v24.2.dll assembly. Add this assembly to your project to use the Workbook API. You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this assembly in production code.

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

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).