The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

Workbook.Merge(IWorkbook[]) Method

Combines the specified workbooks into a new document.

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use this method in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v19.2.dll

Declaration

public static Workbook Merge(
    params IWorkbook[] workbooks
)
Public Shared Function Merge(
    ParamArray workbooks As IWorkbook()
) As Workbook
public static Workbook Merge(
    params IWorkbook[] workbooks
)
Public Shared Function Merge(
    ParamArray workbooks As IWorkbook()
) As Workbook
public static Workbook Merge(
    params IWorkbook[] workbooks
)
Public Shared Function Merge(
    ParamArray workbooks As IWorkbook()
) As Workbook

Parameters

Name Type Description
workbooks IWorkbook[]

An array of IWorkbook objects that are workbooks to be merged.

If one or more workbooks is null, a System.ArgumentNullException exception occurs.

Parameters

Name Type Description
workbooks IWorkbook[]

An array of IWorkbook objects that are workbooks to be merged.

If one or more workbooks is null, a System.ArgumentNullException exception occurs.

Parameters

Name Type Description
workbooks IWorkbook[]

An array of IWorkbook objects that are workbooks to be merged.

If one or more workbooks is null, a System.ArgumentNullException exception occurs.

Returns

Type Description
Workbook

A Workbook object that is the resulting workbook.

Returns

Type Description
Workbook

A Workbook object that is the resulting workbook.

Returns

Type Description
Workbook

A Workbook object that is the resulting workbook.

Remarks

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.

See Also