# Copy and paste ranges

Copy values from a rectangular range and paste them in the same row and column arrangement. Targets are determined from the starting cell and remain subject to editability, permissions, and validation.

Canonical: https://grid.syidax.com/docs/features/range-clipboard/

<a id="understand"></a>

## How it works and when to use it

Even with the same clipboard format, results depend on target columns' number, date, and selection-value contracts. Test a small range first.

Using this feature in a product requires the Pro package and a valid license. Matching setting names do not enable Pro features in Community.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

- [Installation and integration · Shared sample data](https://grid.syidax.com/docs/guides/getting-started.md)

<a id="example-1"></a>

## Example 1. Copy a selected range

Select a range, then copy it from a user button action.

```javascript
grid.rangeSelection = true;
console.log(await grid.copyRangeToClipboard());
```

Verify the result: The selected cell layout is placed on the clipboard. Check the result for an absent selection or browser rejection.

<a id="example-2"></a>

## Example 2. Paste quantities from a spreadsheet

Paste two or three copied numbers into the starting cell of the quantity column.

```javascript
// Call from the user's Paste button
console.log(await grid.pasteFromClipboard());
```

Verify the result: Target quantities and calculated columns update. Invalid formats and noneditable targets may not all be applied in the same way.

<a id="example-3"></a>

## Example 3. Undo a paste

Read the result and undo unintended changes.

```javascript
grid.addEventListener('clipboardPasted', event => console.log(event.detail));
// When the user requests Undo
await grid.undo();
```

Verify the result: Distinguish changed cells from excluded cells. If changes have already been saved to the server, your app must handle reverting them there separately.

<a id="pitfalls"></a>

## Combining features and troubleshooting

Ranges with merged cells or pinned rows may behave differently from regular areas. Use the returned report instead of deriving applied row counts from range dimensions.

Verify that protected columns reject copying and pasting through both UI and API paths.

<a id="related-api"></a>

## APIs used by this feature

- [copyRangeToClipboard](https://grid.syidax.com/docs/methods/copyRangeToClipboard.md) — Copies the selected range and returns success. Check browser permissions and user activation requirements.
- [pasteFromClipboard](https://grid.syidax.com/docs/methods/pasteFromClipboard.md) — Pastes clipboard content into the current target. Inspect applied and skipped cells in the result event.
- [clipboardCopied](https://grid.syidax.com/docs/events/clipboardCopied.md) — Emitted after clipboard copying completes. Output text and ranges are available, so avoid logging sensitive values.
- [clipboardPasted](https://grid.syidax.com/docs/events/clipboardPasted.md) — Reports paste results. Inspect applied/skipped counts, starting position, and actual changes together.

<a id="next"></a>

## Related reading

- [How rows, columns, and IDs relate](https://grid.syidax.com/docs/guides/concepts.md)
- [Connect results and events](https://grid.syidax.com/docs/guides/data-event-access.md)
- [Explore in Features](https://grid.syidax.com/grid/range-clipboard) — The guide describes which interactions are available to try.
