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