You can copy and paste items to and from the grid using the system clipboard.
Copy to clipboard operation can be done in the following ways:
Paste to clipboard can only be done in one way:
The copy operation will copy selected ranges, selected rows, or the currently focused cell, based on this order:
Copy to clipboard is not supported in Safari. This is because the Safari browser does not implement the required API that ag-Grid uses, further details are described here. ag-Grid does not plan to support Safari clipboard as Safari is not generally used in corporate environments where the target audience for this feature resides.
Below you can:
When row click selection and range selection are enabled the shortcut would copy the selected row, not the selected range, if you wish to let the range take precedence, then you can add this to your gridOptions suppressCopyRowsToClipboard:true
If you want to do the copy to clipboard yourself (ie not use the grids clipboard interaction) then implement the callback sendToClipboard(params). Use this if you are in a non-standard web container that has a bespoke API for interacting with the clipboard. The callback gets the data to go into the clipboard, it's your job to call the bespoke API.
The example below shows using sendToClipboard(params), but rather than using the clipboard, demonstrates the callback by just printing the data to the console.
If you wish to process the data before pasting into or out of the Grid, you can use the following call backs to do so:
processCellForClipboard(params):Allows you to process cells for the clipboard. Handy if you have date objects that you need to have a particular format if importing into Excel.
processCellFromClipboard(params):Allows you to process cells from the clipboard. Handy if you have for example number fields, and want to block non-numbers from getting into the grid.
By default, the grid will use '\t' (tab) as the field deliminator. This is to keep the
copy / paste compatible with Excel. If you want another deliminator then use the
The colDef has a property
suppressPaste where you can specify to not allowing
clipboard paste for a particular cell. This can be a boolean or a function (use a function
to specify for a particular cell, or boolean for the whole column).
The example below demonstrates:
clipboardDeliminator=','. To test, copy to clipboard, then paste into a text editor.