setValue or getCell().value() don't update the cell

Posted by: davide.vago on 16 August 2019, 1:23 pm EST

  • Posted 16 August 2019, 1:23 pm EST

    Good morning/afternoon

    I’m trying to inject data once a spread instance has been rendered based on a saved set of data.

    Unfortunately, given a cell instance (getCell) on the active spreadsheet I can’t update the value.

    Within the function which updates the sheet view I do:

    
    this.activeSheet.suspendPaint()
    this.activeSheet.suspendCalcService()
    this.activeSheet.suspendEvent()
    
    this.activeSheet.getCell(row, col).value(newValueGoesHere)
    ---- or ----
    this.activeSheet.setValue(row, col, newValueGoesHere)
    
    this.activeSheet.resumeCalcService()
    this.activeSheet.resumeEvent()
    this.activeSheet.resumePaint()
    
    
    

    this.activeSheet is what comes from getActiveSheet method from your documentation: http://help.grapecity.com/spread/SpreadSheets11/webframe.html#SpreadJS~GC.Spread.Sheets.Workbook~getActiveSheet.html

    Note: I’ve no problems setting up style related values (e.g. backColor) so I’m definitely retrieving the right cell.

  • Posted 19 August 2019, 2:07 am EST

  • Posted 20 August 2019, 4:32 am EST

    Thanks Manish for your reply.

    I figured out that either setValue or getCell().value() are not working when the specified cell contains a formula.

    The only way to replace the value of the cell has been using setFormula()

    It’s fine for now, you might want to pass this information to your developers as I guess it could be a bug

  • Posted 22 August 2019, 6:39 am EST

    Hi Davide,

    We have escalated this case to the devTeam to confirm if this is by design or a bug that needs to be fixed.

    In the meantime, you may override formulas by first clearing the formula and then setting the value. Please refer to the following code snippet:

    sheet.setFormula(rowIdex, colIndex, null); // clear formula
    sheet.setValue(rowIndex, colIndex, "new value"); // set value
    

    Regards

    Sharad

  • Posted 22 August 2019, 6:41 am EST

    The internal tracking ID for the issue is SJS- 1442.

  • Posted 23 August 2019, 10:08 am EST

    Thanks for this.

  • Posted 26 August 2019, 12:11 am EST

    Hi Davide,

    The dev team has confirmed that this behaviour is by design. The formula has higher priority than value, and will always override the value.

Need extra support?

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

Learn More

Forum Channels