Back to Devexpress

WorkbookExtensions.Clone(IWorkbook) Method

officefileapi-devexpress-dot-spreadsheet-dot-workbookextensions-dot-clone-x28-devexpress-dot-spreadsheet-dot-iworkbook-x29.md

latest3.1 KB
Original Source

WorkbookExtensions.Clone(IWorkbook) Method

Creates a workbook copy.

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.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public static Workbook Clone(
    this IWorkbook workbook
)
vb
<ExtensionAttribute>
Public Shared Function Clone(
    workbook As IWorkbook
) As Workbook

Parameters

NameTypeDescription
workbookIWorkbook

An object exposing the IWorkbook interface that specifies the source workbook for copying.

|

Returns

TypeDescription
Workbook

A Workbook object that is the created copy.

|

Remarks

The Clone 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 create copies of the existing workbooks.

csharp
// Add a reference to the DevExpress.Docs.dll assembly.
using DevExpress.Spreadsheet;
// ...

// Create a new Workbook object.
Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx", DocumentFormat.Xlsx);
// Create a copy of the Workbook object.
Workbook copy = workbook.Clone();

// Create a copy of the document loaded into the SpreadsheetControl.
Workbook copy2 = spreadsheetControl.Document.Clone();
vb
' Add a reference to the DevExpress.Docs.dll assembly.
Imports DevExpress.Spreadsheet
' ...

' Create a new Workbook object.
Private workbook As New Workbook()
workbook.LoadDocument("Document.xlsx", DocumentFormat.Xlsx)
' Create a copy of the Workbook object.
Dim copy As Workbook = workbook.Clone()

' Create a copy of the document loaded into the SpreadsheetControl.
Dim copy2 As Workbook = spreadsheetControl.Document.Clone()

See Also

WorkbookExtensions Class

WorkbookExtensions Members

DevExpress.Spreadsheet Namespace