.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

PasteSpecial Enum

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

Namespace: DevExpress.Spreadsheet

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

Declaration

public enum PasteSpecial

Members

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.

Remarks

The PasteSpecial enumeration members are used by the CellRange.CopyFrom method. Refer to the following examples for details:

Example

This example demonstrates how to copy data from one cell to another, and specify which parts of the copied data (for example, value only, formatting information only, borders only, etc.) should be pasted into the destination cell. To do this, call the CellRange.CopyFrom method of the Cell object corresponding to the cell into which you want to copy data from another cell. Pass the source cell object and required member of the PasteSpecial enumerator as parameters.

Worksheet worksheet = workbook.Worksheets[0];
worksheet.Columns["A"].WidthInCharacters = 32;
worksheet.Columns["B"].WidthInCharacters = 20;
Style style = workbook.Styles[BuiltInStyleId.Input];

// Specify the content and formatting for a source cell.
worksheet.Cells["A1"].Value = "Source Cell";

Cell sourceCell = worksheet.Cells["B1"];
sourceCell.Formula = "= PI()";
sourceCell.NumberFormat = "0.0000";
sourceCell.Style = style;
sourceCell.Font.Color = Color.Blue;
sourceCell.Font.Bold = true;
sourceCell.Borders.SetOutsideBorders(Color.Black, BorderLineStyle.Thin);

// Copy all information from the source cell to the "B3" cell. 
worksheet.Cells["A3"].Value = "Copy All";
worksheet.Cells["B3"].CopyFrom(sourceCell);

// Copy only the source cell content (e.g., text, numbers, formula calculated values) to the "B4" cell.
worksheet.Cells["A4"].Value = "Copy Values";
worksheet.Cells["B4"].CopyFrom(sourceCell, PasteSpecial.Values);

// Copy the source cell content (e.g., text, numbers, formula calculated values) 
// and number formats to the "B5" cell.
worksheet.Cells["A5"].Value = "Copy Values and Number Formats";
worksheet.Cells["B5"].CopyFrom(sourceCell, PasteSpecial.Values | PasteSpecial.NumberFormats);

// Copy only the formatting information from the source cell to the "B6" cell.
worksheet.Cells["A6"].Value = "Copy Formats";
worksheet.Cells["B6"].CopyFrom(sourceCell, PasteSpecial.Formats);

// Copy all information from the source cell to the "B7" cell except for border settings.
worksheet.Cells["A7"].Value = "Copy All Except Borders";
worksheet.Cells["B7"].CopyFrom(sourceCell, PasteSpecial.All & ~PasteSpecial.Borders);

// Copy information only about borders from the source cell to the "B8" cell.
worksheet.Cells["A8"].Value = "Copy Borders";
worksheet.Cells["B8"].CopyFrom(sourceCell, PasteSpecial.Borders);
See Also