Skip to main content
All docs
V25.1
  • Row

    WorksheetCopyOptions.PasteOptions Property

    Specifies the part of data to paste from the copied worksheet into the target worksheet.

    Namespace: DevExpress.Spreadsheet

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

    NuGet Package: DevExpress.Spreadsheet.Core

    Declaration

    public PasteSpecial PasteOptions { get; set; }

    Property Value

    Type Description
    PasteSpecial

    One or more Paste Special options.

    Available values:

    Name Description
    Formulas

    Pastes cell constant values (for example, text, numbers, and so on) and formulas (but not their calculated values).

    Values

    Pastes cell values only (including values calculated from formulas, but not formulas themselves).

    NumberFormats

    Pastes cell number formats only.

    Borders

    Pastes cell borders only.

    Formats

    Pastes cell formatting only (font, background, alignment, number format, and borders).

    Comments

    Pastes cell comments only.

    ColumnWidths

    Applies column widths only.

    DataValidations

    Pastes only data validation rules applied to copied cells.

    Pastes hyperlinks only (without display text).

    All

    Pastes all cell data (formulas, values, and formatting) except column widths.

    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