How to: Merge Multiple Workbooks Into One Document

IMPORTANT

The Universal Subscription or an additional Office File API Subscription is required to use this example in production code. Refer to the DevExpress Subscription page for pricing information.

This example demonstrates how to add all worksheets from one workbook to another spreadsheet document using the WorkbookExtensions.Append extension method. Workbook extensions are defined by the WorkbookExtensions class. To enable them, add a reference to the DevExpress.Docs.v20.1.dll library and explicitly import the DevExpress.Spreadsheet namespace into your source code with a using directive (Imports in Visual Basic).

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

// Create a new Workbook object.
Workbook book1 = new Workbook();
book1.LoadDocument("Document1.xlsx", DocumentFormat.Xlsx);

// Load a document into SpreadsheetControl.
IWorkbook book2 = spreadsheetControl.Document;
book2.LoadDocument("Document2.xlsx", DocumentFormat.Xlsx);

// Copy all worksheets from "Document1" into the SpreadsheetControl's document. 
book2.Append(book1);