Clipboard
25 Mar 20213 minutes to read
The Spreadsheet provides support for the clipboard operations (cut, copy, and paste). Clipboard operations can be enabled or disabled by setting AllowClipboard
property in Spreadsheet.
By default AllowClipboard
property is true
.
Cut
This function cuts the selected range values and make it available in clipboard.
You can do this by one of the following ways.
- Using “Ctrl-X” key.
- Using Cut button of HOME tab in ribbon to perform cut operation.
- Using Cut option in Context Menu.
- Using
cut
method.
Copy
This function copies the selected range values and make it available in clipboard.
You can do this by one of the following ways.
- Using “Ctrl-C” key.
- Using Copy button of HOME tab in ribbon to perform copy operation.
- Using Copy option in Context Menu.
- Using
copy
method.
Paste
This function pastes the clipboard content to newly selected range. If you perform cut paste, clipboard contents are cleared whereas in copy paste the clipboard contents are maintained.
You have following options in Paste.
- Paste Special - You can paste the values with formatting.
- Paste - You can paste only the values.
NOTE
The default paste option is Paste Special. This is working only within the current Spreadsheet. If you copy the content from other sources, it will paste only the values in the Spreadsheet.
You can do this by one of the following ways,
- Using “Ctrl-V” key.
- Using Paste button of HOME tab in ribbon to perform paste operation.
- Using Paste option in Context Menu.
- Using
paste
method.
The following code example describes the above behavior.
<ej:Spreadsheet ID="FlatSpreadsheet" AllowClipboard = "true" runat="server">
<ClientSideEvents LoadComplete="loadComplete" />
</ej:Spreadsheet>
<script type="text/javascript">
function loadComplete() {
var excelClip = this.XLClipboard;
this.performSelection("G1:H3");
exceClip.cut(); // Cut the selected cells
//exceClip.copy();//Copy the selected cells.
this.performSelection("J4");
exceClip.paste();
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataSource();
}
}
private void BindDataSource()
{
var dataSource = new OrderItemsDataContext().GetAllItemDetails.ToList();
this.FlatSpreadsheet.Sheets.Add(new Syncfusion.JavaScript.Models.Sheet()
{
Datasource = dataSource
});
}
The following output is displayed as a result of the above code example.
NOTE
Similarly you can perform clipboard operations for shapes( Chart and Image).