Missing "Copied" cell border format SpreadJs

Posted by: nhan.thanh.nguyen on 16 March 2023, 8:38 pm EST

    • Post Options:
    • Link

    Posted 16 March 2023, 8:38 pm EST - Updated 16 March 2023, 8:49 pm EST

    Hi teams,

    I have problems with copying/pasting the clipboard.



    After I have pasted the formula to the cell, the source cell is missing “Copied” border, I found that when I use setFormula function inside ClipboardPasted, It will miss the “Copied” Cell border, I have paste with pasteOption is values.

    My case need to check if source cell has formula then we will paste down formula, if don’t have formula it will paste down the values.

    And do we have any functions or ways to mark a cell as “Copied”?



    If I copy a cell with text inside (just string not formula). It still keeps “Copied” cell border

    I’m using SpreadJs 14 version with ReactJs

    I’m looking forward to hearing from you,

    Thanks and Best Regards,

    Nhan Nguyen

  • Posted 19 March 2023, 7:44 pm EST

    Hello,

    As I can understand, when the ClipboardPasted event is fired then you use setFormula() method to paste formula if the copied cell contains a formula.

    Please note that whenever there are any changes(e.g. edit cell, entering formula) to cell in the worksheet after copying, then the internal clipboard of the SpreadJS is cleared and copied cells’s dashed border also disappears. This behavior aligns with the behavior of MS Excel and it is by design.

    You can use the spread.suspendEvent() method to suspend the events in spreadjs so that the internal clipboard is not cleared when you use setFormula() method.

    Please refer to the code snippet and attached sample for further understanding.

    spread.bind(GC.Spread.Sheets.Events.ClipboardPasted, (event, args) => {

    let row = args.cellRange.row;

    let col = args.cellRange.col;

    let sheet = args.sheet;

    let formula = sheet.getFormula(row, col);

    let activeRow = sheet.getActiveRowIndex();

    let activeCol = sheet.getActiveColumnIndex();

    if (formula) {

    spread.suspendEvent();

    sheet.setFormula(activeRow, activeCol, formula);

    spread.resumeEvent();

    }

    });

    Sample:sample.zip

    Doc reference

    spread.resumeEvent(): https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Workbook#resumeevent

    spread.suspendEvent():https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Workbook#suspendevent

    regards,

    Avinashsample (1).zip

  • Posted 19 March 2023, 8:02 pm EST

    Thank you very much for your reply, this solved my case. when I use suspendEvent() and resumeEvent() inside ClipboardPasted

Need extra support?

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

Learn More

Forum Channels