WorkbookExtensions.Append(IWorkbook, IWorkbook[]) Method
Appends all worksheets from the specified workbooks to the current workbook.
You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this method in production code.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Docs.v24.1.dll
NuGet Package: DevExpress.Document.Processor
Declaration
Parameters
Name | Type | Description |
---|---|---|
workbook | IWorkbook | An object exposing the IWorkbook interface that is a master workbook to which other workbooks should be added. |
workbooks | IWorkbook[] | An array of IWorkbook objects that are workbooks that should be merged with a master workbook. If one or more workbooks is null, a System.ArgumentNullException exception occurs. |
Remarks
The Append method is an extension method of the object that exposes the IWorkbook interface (SpreadsheetControl.Document or non-visual Workbook) and is called by using instance method syntax.
The following example demonstrates how to copy all worksheets from the workbook named Document1 into the workbook Document2.
// 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);
If a workbook being merged contains a worksheet with the same name as a worksheet that already exists in the master workbook, the added worksheet is automatically renamed and all cell references containing this worksheet name are updated to use a new name. For instance, if you’re trying to merge workbooks containing worksheets named “Sheet1” with a master 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.
To combine all workbooks into a new summary workbook, use the static Workbook.Merge method.