Copy paste full row with locked cells

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

  • 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.
  • Replied 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
Need extra support?

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

Learn More

Forum Channels