How to: Merge Multiple Workbooks Into One Document
- 2 minutes to read
Important
The Workbook class is defined in the DevExpress.
Use one of the following methods to combine data from multiple workbooks into a single document.
Method | Description |
---|---|
Workbook |
Appends all worksheets from the specified workbooks to the current workbook. |
Workbook. |
Combines specified workbooks into a new document. |
#Copy Workbooks to Another Document
// Add a reference to the DevExpress.Docs.dll assembly.
using DevExpress.Spreadsheet;
// ...
// Create the first workbook.
Workbook book1 = new Workbook();
book1.LoadDocument("Document1.xlsx", DocumentFormat.Xlsx);
// Create the second workbook.
Workbook book2 = new Workbook();
book2.LoadDocument("Document2.xlsx", DocumentFormat.Xlsx);
// Copy all worksheets from "Document1" to "Document2".
book2.Append(book1);
#Merge Workbooks into a New Document
// Add a reference to the DevExpress.Docs.dll assembly.
using DevExpress.Spreadsheet;
// ...
// Create the first workbook.
Workbook book1 = new Workbook();
book1.LoadDocument("Document1.xlsx", DocumentFormat.Xlsx);
// Create the second workbook.
Workbook book2 = new Workbook();
book2.LoadDocument("Document2.xlsx", DocumentFormat.Xlsx);
// Combine two documents into a new document.
Workbook result = Workbook.Merge(book1, book2);