Custom name with Undo operation

Posted by: diegoar27 on 11 January 2018, 12:54 am EST

    • Post Options:
    • Link

    Posted 11 January 2018, 12:54 am EST

    Hi!

    I’m having an issue with the undo operation, this are the steps to reproduce it.

    I have an empty spreadsheet and I want create a custom name associated to the cell A1, I want to delete the column 0 or row 0 then I want to undo this operation and as result I want to have the custom name restore back.

    Steps:

    
    // Create custom name
    spreadsheet.workbook.addCustomName('test_a1', 'Sheet1!$A$1', 0, 0)
    spreadsheet.workbook.getCustomName('test_a1').getExpression() //-> result: "{"type":1,"row":0,"column":0,"rowRelative":false,"columnRelative":false,"sf":true}"
    
    spreadsheet.workbook.getActiveSheet().setFormula(0, 2, '=test_a1')
    
    // Delete the column 0 and check the custom name state
    spreadsheet.workbook.getActiveSheet().deleteColumns(0, 1)
    spreadsheet.workbook.getCustomName('test_a1').getExpression() //-> result: "{"type":5,"value":{"_calcError":"#REF!","_code":23}}"
    spreadsheet.workbook.getActiveSheet().getValue(0, 1) //-> result: "{"_calcError":"#REF!","_code":23}"
    
    // I want undo the delete column operation 
    spreadsheet.workbook.undoManager().undo() //-> result: true
    
    // I will check the custom name that I had associated to the column 0 
    spreadsheet.workbook.getCustomName('test_a1').getExpression() //-> result: "{"type":5,"value":{"_calcError":"#REF!","_code":23}}"
    spreadsheet.workbook.getActiveSheet().getValue(0, 1) //-> result: "{"_calcError":"#REF!","_code":23}"
    
    

    The result that I’m expecting is get the custom name as I had before the delete column operation.

    Do you know any workaround to do that?

    Thanks in advance.

  • Posted 12 January 2018, 1:28 am EST

    Hello,

    You can save the JSON before deleting the column and then reload when undo. This way you can see the custom name there.

    Thanks,

    Deepak Sharma

  • Posted 12 January 2018, 2:26 am EST

    Hello @deepak, thanks for you answer,

    It’s not the way that I expect to make that operation, I want to do something with better performance. Do you know if that bug will fix in a future or if SpreadJS will add support to do that in future releases?

    Thanks

  • Posted 15 January 2018, 2:01 am EST

    Hello,

    You must be depelting the column in code and that action can not be undone with default Undomanager. You would need to write custom code to undo the delete and restore the formula.

    Please refer to a sample html page.

    Thanks,

    Deepak Sharma

  • Posted 15 January 2018, 2:04 am EST

    Here is the attachment.

    Thanks,

    Deepak SharmaDeleteColumn_Undo_Formula.html.zip

Need extra support?

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

Learn More

Forum Channels