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

WorkbookExtensions.Append(IWorkbook, IWorkbook[]) Method

Appends all worksheets from the specified workbooks to the current workbook.

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 void Append(
    this IWorkbook workbook,
    params IWorkbook[] workbooks
)
<ExtensionAttribute>
Public Shared Sub Append(
    workbook As IWorkbook,
    ParamArray workbooks As IWorkbook()
)
public static void Append(
    this IWorkbook workbook,
    params IWorkbook[] workbooks
)
<ExtensionAttribute>
Public Shared Sub Append(
    workbook As IWorkbook,
    ParamArray workbooks As IWorkbook()
)
public static void Append(
    this IWorkbook workbook,
    params IWorkbook[] workbooks
)
<ExtensionAttribute>
Public Shared Sub Append(
    workbook As IWorkbook,
    ParamArray workbooks As IWorkbook()
)

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.

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.

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.

See Also