[]
In SpreadJS, users can insert cut or copied cells in any spreadsheet of a workbook by using 'Insert Cut/ Copied Cells' option from the context menu. While inserting cells, the context menu provides 2 sub-options:
Shift Cells Right
Shift Cells Down
Shift cells right : When a cut or copied cell(s) is inserted, any data item(s) to the right shifts further towards right (the number of columns shifted is equal to the number of inserted cells).
The following GIF illustrates the behavior of existing data, span or table when they are shifted towards right.
The following GIF illustrates that an exception is thrown if the existing span or table needs to be split while shifting towards right.
Shift cells down : When a cut or copied cell(s) is inserted, any data item(s) below it shifts downwards (the number of rows shifted is equal to the number of inserted cells).
The following GIF illustrates the behavior of existing data, span or table when they are shifted downwards.
The following GIF illustrates that an exception is thrown if the existing span or table needs to be split while shifting downwards.
You can also use 'Insert cut or copied cells' option to insert data in row or column headers. The total number of columns or rows in the spreadsheet should be divisible by the number of cells to be inserted. Otherwise, the 'Insert cut or copied cells' option won't be displayed in the context menu. The data of cut or copied cells is replicated throughout the row or column header.
The following GIF illustrates a spreadsheet which contains 210 rows and 20 columns. When data of 3 columns is copied and inserted in a row header, the ‘Insert copied cells’ option is not displayed as 20 is not divisible by 3. Whereas when the data of 2 columns is copied and inserted in a row header, it gets successfully inserted as 20 is divisible by 2.
When the data of 4 rows is inserted in a column header, the ‘Insert copied cells’ option is not displayed as 210 is not divisible by 4. Whereas when the data of 3 rows is inserted in a column header, it gets successfully inserted as 210 is divisible by 3.
You can also use the ‘Insert cut or copied cells’ option to insert the data in a table. Although, to paste the data of cut/copied cells to the target table, there are different scenarios which are discussed below:
In Row Direction
In Column Direction
In Row Direction: When the source is the whole row and the total number of columns with data is less than or equal to the total number of columns in the target table, cut/ copied data is inserted in the table range as the following GIF illustrates:
Similarly, the following table illustrates other scenarios and their respective behavior as GIFs.
Cases | Result | Image/ GIF |
---|---|---|
The non-null range’s colCount > target table’s colCount |
| |
When the source range is not the whole row and
A- Source's colCount of cut/ copied range
B- Target Table’s colCount range
C- Sheet's colCount
The following GIF illustrates a spreadsheet which contains 210 rows and 20 columns, and the target table is at the first column. When the data of 4 columns is copied and inserted in a row header, the ‘Insert copied cells’ option is displayed and it expands the table and inserts the rows.
Similarly, the following table illustrates other scenarios and their respective behavior as GIFs.
Cases | Detail | Operation (Cut/ Copy) | |
---|---|---|---|
Copy: | Cut: | ||
If (C%A===0) | If the table starts at col 0: | Table expands in column and insert rows.
| A===B, Insert rows
|
If the table does not start at col 0 | Insert Rows
| A<=Table’s Col: Paste
| |
If A=== Table’s col+B | Paste without repeating
| ||
If (C%A!==0)
| If the table starts at col 0: |
|
|
If the table does not start at col 0 |
| ||
Other Scenarios | Source range above Target table | Error message: | |
Source range below Target table | Error message:
|
In Column Direction: Here
D: Row count of cut/ copy range
E: Row count of table range
Cases | Detail | Operation (Cut/ Copy) |
---|---|---|
If D===E+Table’s start row | If the table starts at row 0: | Insert at first col: Table shifts right and insert cols & insert not at first table col: paste
|
If the table does not start at row 0 | Insert at first col: Table shifts right and insert cols & insert not at first table col: Error message
| |
If D< Table’s start row | Paste
| |
If D!==E+ Table’s start row | Error Message:
|
Note: Data is not inserted if the row area already contains any other data or span.