Combines the specified workbooks into a new document.
An array of IWorkbook objects that are workbooks to be merged.
If one or more workbooks is null, a System.ArgumentNullException exception occurs.
A Workbook object that is the resulting workbook.
Use the Merge method to merge data from multiple 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);
If workbooks being merged contain worksheets with the same name, the added worksheets are automatically renamed and all cell references containing the duplicating worksheet names are updated to use the new names. For instance, if you're trying to merge workbooks containing worksheets named "Sheet1" with a workbook where "Sheet1" already exists, these new worksheets will be renamed in the following way: "Sheet1 (2)", "Sheet1 (3)", etc. To rename a worksheet, use the Worksheet.Name property of the corresponding Worksheet object.
Use the WorkbookExtensions.Append method to add the specified workbooks to an existing workbook that calls the Append method.