All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

Worksheet.CopyFrom(Worksheet, WorksheetCopyOptions) Method

Copies data from the specified worksheet to the current worksheet and allows you to specify copy options.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.1.Core.dll

Declaration

void CopyFrom(
    Worksheet source,
    WorksheetCopyOptions options
)

Parameters

Name Type Description
source Worksheet

The source worksheet.

options WorksheetCopyOptions

An object that defines copy options.

Example

The following example copies all data from one worksheet to another except for cell comments:

using DevExpress.Spreadsheet;
// ...

using (Workbook sourceWorkbook = new Workbook())
using (Workbook targetWorkbook = new Workbook())
{
    targetWorkbook.LoadDocument(@"Documents\Book1.xlsx");
    sourceWorkbook.LoadDocument(@"Documents\Book2.xlsx");
    // Add a new worksheet to the destination workbook.
    targetWorkbook.Worksheets.Add("Sheet1_Copy");
    // Specify copy options.
    var copyOptions = new WorksheetCopyOptions()
    {
        // Copy all data except for cell comments. 
        PasteOptions = PasteSpecial.All & ~PasteSpecial.Comments
    };
    // Copy data from "Sheet1" in the source workbook
    // to the newly created worksheet in the destination workbook. 
    targetWorkbook.Worksheets["Sheet1_Copy"].CopyFrom(sourceWorkbook.Worksheets["Sheet1"], copyOptions);
    targetWorkbook.SaveDocument("Result.xlsx");
}
See Also