react-datasheet icon indicating copy to clipboard operation
react-datasheet copied to clipboard

Bug: Copy and paste from MS Excel on a Windows machine pastes an extra empty cell

Open haihoang20 opened this issue 4 years ago • 2 comments

There's a bug that happens on Windows where copying and pasting multiple cells from MS Excel will paste an extra empty cell. This can unintentionally overwrite existing cells as seen in the screenshot. image image

This bug is reproducible on the demo as well https://nadbm.github.io/react-datasheet/

This does not happen on Mac.

haihoang20 avatar Nov 19 '21 17:11 haihoang20

If anyone comes across this issue, it can be easily fixed by using the parsePaste prop on the <DataSheet> component, and pass it a modified version of the default function with an added .trim() call:

<DataSheet
  parsePaste={(pastedString) => {
    return pastedString.trim().split(/\r\n|\n|\r/).map(row => row.split('\t'))
  }
/>

Fixed the issue for me

christiankaindl avatar Jan 27 '22 09:01 christiankaindl