.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
A newer version of this page is available. Switch to the current version.

PasteSpecial Enum

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

Namespace: DevExpress.Spreadsheet

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


public enum PasteSpecial


Name Description

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


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


Pastes cell number formats only.


Pastes cell borders only.


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


Pastes cell comments only.


Applies column widths only.


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


The PasteSpecial enumeration values are used by the Range.CopyFrom method. For details, refer to the How to: Copy Cell Data Only, Cell Style Only, or Cell Data with Style and How to: Copy a Row or Column examples.


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 Range.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";

// 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