There are several Clipboard operations (such as copy, cut, and paste) that are automatically set for a sheet with default settings; they are built-in to Spread. But Spread also gives you the ability to customize these operations on actual applications that you develop, depending on your specific needs. You can customize how the user can interact with the contents of the Clipboard when users perform copying and pasting actions in cells in the spreadsheet. You can implement those operations at your discretion in code. These customizations include:
- Deactivating Clipboard Operations
- Excluding Headers from Clipboard Operations
- Obtaining the Clipboard Contents
- Deactivating Pasting
- Changing the Scope of Pasting
- Performing the Clipboard Operations in Code
The following members are used to determine Clipboard-related interaction:
- ClipboardOptions property (and ClipboardOptions enumeration)
- AutoClipboard property
- ClipboardCopyOptions enumeration
- ClipboardPasteOptions enumeration
The spreadsheet methods in the SheetView class that involve Clipboard operation are:
- ClipboardCopy, which copies the contents from the sheet to the Clipboard
- ClipboardCut, which cuts the contents from the sheet to the Clipboard
- ClipboardPaste, which pastes the contents from the Clipboard to the sheet
The corresponding shape methods in the SheetView class that involve Clipboard operation are:
- ClipboardCopyShape, which copies the active shape to the Clipboard
- ClipboardCutShape, which cuts the active shape to the Clipboard
- ClipboardPasteShape, which pastes the shape from the Clipboard
If there are locked cells in the range to cut or paste then the Clipboard operation is aborted. The .NET version of the product handles Clipboard operations differently from the way that the COM version does.
You can also set how some Clipboard-related features perform when the user is in edit mode in a cell on the Spread. You can set whether the pop-up menu appears while in edit mode within a cell using the AutoMenu property in SuperEditBase class and whether the user can perform Clipboard operations with the shortcut keys with the AllowClipboardKeys property in SuperEditBase class.
For more information on copying and pasting, refer to Copying Data on a Sheet.Deactivating Clipboard Operations
You can set whether the shortcut keys are available to the end user for them to use to perform Clipboard operations by setting the AutoClipboard property in the FpSpread class.You can deactivate all the Clipboard operations with components by specifying False to the AutoClipboard property in the FpSpread class (The default setting is True).You can deactivate some Clipboard operations such as Pasting (Ctrl+V) by deactivating the input map definition for short-cut keys and Clipboard operations (Ctrl+C, Ctrl+V, and Ctrl+X).
Excluding Headers from Clipboard Operations
You can set whether to include headers or not when performing Clipboard operations. This can be done with the ClipboardOptions property in the FpSpread class and the ClipboardOptions enumeration. By configuring the ClipboardOptions property in the FpSpread class, you can specify whether row headers or column headers are processed when Clipboard operations are used. (The default setting, AllHeaders, allows all headers to be included).
Obtaining the Clipboard Contents
Values which are copied on sheets are controlled by Clipboard class which is provided from the .NET Framework. You can obtain Clipboard contents by using respective operations in this Clipboard class.
Cell data is copied onto Clipboard in advance by calling ClipboardCopy method in SheetView class at the Load event. Then, calling GetDataObject method enables you to obtain those Clipboard contents for text format determination, for example.
Deactivating Pasting
The ClipboardPasting event occurs when pasting is executed (Ctrl+V) on sheets. You can deactivate pasting by canceling this event under certain circumstances. You can prevent pasting by obtaining the timing when pasting is executed, and canceling the action.
Changing the Scope of Pasting
When cells are copied or cut to the Clipboard, all the data aspects including values, formats, and formulas, are available by default for pasting. You can configure to paste values only, for example, by changing the input map definitions. The default setting is ClipboardPasteAll, which enables pasting all the aspects of the data. The ClipboardPasteOptions enumeration allows you to set the scope of what is pasted when a Clipboard paste is performed by the user.
Performing the Clipboard Operations in Code
Various methods are provided in the SheetView class for Clipboard processes. You can run them when you want. These include:
- ClipboardCopy
- ClipboardCopyShape
- ClipboardCut
- ClipboardCutShape
- ClipboardPaste
- ClipboardPasteShape