When working in SpreadJS, you may encounter an issue when copying and pasting rows near the end of a worksheet. For example, if your sheet contains 50 rows and you copy rows 1–10, then attempt to paste them starting at row 50, you may see the following error message:
"The copy and paste areas are not the same size."
In this scenario, the worksheet does not automatically expand to include the new rows, and the paste operation fails but in fact, this is the default behavior in SpreadJS. By default, SpreadJS does not allow pasting into a range that extends beyond the existing worksheet boundaries. This means that if you try to paste rows below the current row count, the operation will fail with the error above.
To enable Excel-like behavior where the worksheet automatically expands to accommodate the pasted data, you should turn on the allowExtendPasteRange option.
// Enable automatic range extension when pasting
spread.options.allowExtendPasteRange = true;
The allowExtendPasteRange feature allows the sheet to grow automatically when pasting beyond the current row or column limits. This makes copying and pasting large ranges much more intuitive, especially when working with dynamic or growing datasets.
For more information about paste operations and worksheet options, please refer to the official SpreadJS documentation.
Kristina Ismail