Copy paste full row with locked cells

Posted by: bsnthr on 1 August 2022, 6:04 pm EST

    • Post Options:
    • Link

    Posted 1 August 2022, 6:04 pm EST

    Hello,

    I currently face an issue where I need to be to copy paste a full row that contains some locked cells.

    I have provided a minimal example here:

    https://jscodemine.grapecity.com/sample/ZSVPVxc0b0iKmitIg6FOMQ/

    It consists of three columns, where one column is completely locked.

    When trying to copy/paste a full row it throws the InvalidOperation error:

    The cell you are trying to change is protected and therefore read-only
    

    When only copy/pasting the unlocked cells it works fine.

    I tried to hook into the ClipboardPasting listener to be able to set the sheet.options.isProtected to false (and setting it to true in ClipboardPasted again), but it seems the InvalidOperation cancels the event and the ClipboardPasting listener does not get triggered.

    The ideal scenario would be to skip the locked cells on pasting, because they are automatically filled based on values in some unlocked cells. (Actually I have already that code in place in the ClipboardPasting listener, but as it is not triggered I am not able to do so).

    BTW is there some consulting services that you offer for investigating current painpoints that we face with the framework?

    Thanks in advance.

  • Posted 1 August 2022, 10:44 pm EST

    The correct link for the example is this one:

    https://jscodemine.grapecity.com/sample/kmULt6dn1kCh5cGOcfq1rQ/

  • Posted 2 August 2022, 8:04 pm EST

    Hi,

    When you are pasting within the locked cells range, it will give the Invalid Operation. This behavior is same as that of Microsoft Excel.

    Based on your use case, You can check if the invalid operation is of type “copyPaste”, and then execute the paste command on the non-locked cells.

    Note: If you try to paste on the locked cells, it will give the Invalid Operations.

    For example, I have created a sample for you. In the sample, you can execute the code inside the “pasteProtected” command: https://jscodemine.grapecity.com/share/gwrmYfl2t02THvOTWBpyhw/

    API Docs:

    ClipboardPaste: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Sheets.Commands~clipboardPaste.html

    register method:

    https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Commands.CommandManager~register.html

    Regards

    Ankit

  • Posted 8 December 2022, 11:58 pm EST

    Hi Ankit

    This post is almost about the same problem that we have. Only that in our case the data to be inserted does not come from SpreadJS, but from Excel.

    This means that overriding the copy and cut commands does not help us.

    Is there a way to get the clipboard data before the invalid operation occurs?

    Thanks for any help!

    Matthias

  • Posted 9 December 2022, 2:05 am EST

    Never mind… i managed to read and parse the value from the clipboard.

  • Posted 11 December 2022, 5:46 pm EST

    Hi,

    We are happy that your issue has been resolved. As explained above, you can check if the invalid operation is of type “copyPaste”, and then execute the paste command on the non-locked cells.

    Regards,

    Ankit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels