nadbm / react-datasheet

Excel-like data grid (table) component for React
https://nadbm.github.io/react-datasheet/
MIT License
5.39k stars 457 forks source link

Paste more rows than that is defined by the `grid`. #328

Closed hamodey closed 2 years ago

hamodey commented 2 years ago

Hi,

Lets say I have a Grid of 5 Rows and 3 columns, however in my excel I have 10 Rows and 3 columns.

Using the onCellChanged and possibly the pasteParser I would like to generate 10 Rows in my grid.

Currently the Datasheet looks like this: image

I would like to paste this data: image

To end up looking like this:

image

From reading the source code I can see that there is:

parsePaste={(pasted) => {
         //do something
        }}

However, this seems to overwrite the current paste functionality, is there a way I can extend that approach?

Thank you :)

BaherZ commented 2 years ago

onCellsChanged takes in 2 params, "changes" and "additions", you can use the additions to see the data that you copied that do not have a place to copy yet, you can then work with that info to add additional rows to your sheet

hamodey commented 2 years ago

Awesome, thanks for response I will have a look at that approach.

I have had some time to apply functionality that does the above, but has small bugs for row length.

I will take yours into account and see if that helps! :)