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

WorksheetCopyOptions.OverwriteProtectionOnLockedWorksheet Property

Specifies whether to apply cell protection options of the source worksheet to cells in the protected destination worksheet.

Namespace: DevExpress.Spreadsheet

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

Declaration

public bool OverwriteProtectionOnLockedWorksheet { get; set; }

Property Value

Type Description
Boolean

true if cells in the protected destination worksheet have the same protection options as the source worksheet cells; overwise, false (default).

Remarks

If a worksheet where you paste data is protected, you can set the OverwriteProtectionOnLockedWorksheet property to true to copy cell protection settings from the source worksheet and apply them to cells in the destination worksheet.

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.
    Worksheet targetSheet = targetWorkbook.Worksheets.Add("Sheet1_Copy");
    // Protect the worksheet.
    targetSheet.Protect("password", WorksheetProtectionPermissions.Default);
    // Specify copy options.
    var copyOptions = new WorksheetCopyOptions()
    {
        OverwriteProtectionOnLockedWorksheet = true
    };
    // Copy data from "Sheet1" in the source workbook
    // to the newly created worksheet in the destination workbook. 
    targetSheet.CopyFrom(sourceWorkbook.Worksheets["Sheet1"], copyOptions);
    targetWorkbook.SaveDocument("Result.xlsx");
}
See Also