ClipboardPasteOptions doesn't permit to select values and formulas only

Posted by: davide.vago on 28 November 2019, 1:27 am EST

  • Posted 28 November 2019, 1:27 am EST

    Good morning/afternoon

    I’m reaching you out as I was going through the documentation related to the clipboard copy/paste functionality and I found out that the current way to set what the user copies and pastes is to use the attribute ClipboardPasteOptions within the Sheet instance options.

    However, there is no way to configure the paste action to paste just values and formulas.

    In fact, GC.Spread.Sheets.ClipboardPasteOptions.values copies just the value of the cell but not formulas.

    I’m currently trying to give the user the possibility to paste cells without including tags, therefore the most appropriate option is GC.Spread.Sheets.ClipboardPasteOptions.all but I can’t see how to exclude existing cell tags. (note: resetting the tags with setTag(null) is not an option for me)

    Ref. https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.ClipboardPasteOptions.html

  • Posted 28 November 2019, 7:46 pm EST

    Hi Davide,

    We have asked to confirm if it is possible to achieve the required functionality using the current API and will let you as soon as I get an update. The internal tracking Id for the issue is SJS-2706.

    Regards

    Sharad

  • Posted 9 December 2019, 2:15 am EST

    Dear Sharad,

    Do you have any update on this request, please?

    Thanks for your support.

  • Posted 9 December 2019, 2:48 pm EST

    Hi Davide,

    The issue is still is with devteam. I’ve asked the team to provide an update, will let you know as soon I get an update.

    Regards

  • Posted 27 January 2020, 10:07 pm EST

    Good morning/afternoon.

    Is it possible to have an update on this issue, we have in our backlog a series of issues correlated to this missing feature.

    Looking forward to hear from you

  • Posted 30 January 2020, 6:23 pm EST

    Hi Davide,

    We apologize for the delay, the issue is with the dev team. I’ve escalated the case to the PM and will be looking at it on priority.

    Thank you for your cooperation.

    Regards

    Sharad

  • Posted 2 February 2020, 5:43 pm EST

    Hi Davide,

    The Devs have suggested to cache the tags in ClipboardPasting event and then restore the tags back in the ClipboardPasted event. Please refer to the following code snippet and the sample demonstrating the same:

    var cachedTags = null;
    
      spread.bind(GC.Spread.Sheets.Events.ClipboardPasting, function(e, args) {
        // save current tags
        var _tags = [];
        for (
          var i = args.cellRange.row;
          i < args.cellRange.row + args.cellRange.rowCount;
          i++
        ) {
          var colTags = [];
          for (
            var j = args.cellRange.col;
            j < args.cellRange.col + args.cellRange.colCount;
            j++
          ) {
            colTags.push(args.sheet.getTag(i, j));
          }
          _tags.push(colTags);
        }
        cachedTags = _tags;
      });
    
      spread.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(e, args) {
        // restore tags
    
        args.sheet.suspendPaint();
        var _tags = cachedTags;
        for (
          var i = args.cellRange.row;
          i < args.cellRange.row + args.cellRange.rowCount;
          i++
        ) {
          var colTags = _tags[i - args.cellRange.row];
          for (
            var j = args.cellRange.col;
            j < args.cellRange.col + args.cellRange.colCount;
            j++
          ) {
            colTags.push(args.sheet.setTag(i, j, colTags[j - args.cellRange.col]));
          }
        }
        args.sheet.resumePaint();
        cachedTags = null;
      });
    

    https://codesandbox.io/s/spread-js-starter-9r42j

    Regards

    Sharad

Need extra support?

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

Learn More

Forum Channels