Having problem getting proper cell references when calling getFormula()

Posted by: james.henke on 23 September 2019, 4:24 pm EST

  • Posted 23 September 2019, 4:24 pm EST

    I have a spreadsheet with a cell that has the formula of “=SUM(a1:c1)”. When I call sheet.getFormula(row, column) or cell.formula(), I’m getting “SUM(XDX1048555:XER1048555)”.

    Is there something else I’m suppose to be doing before or after the call?

  • Posted 24 September 2019, 2:20 am EST

    Hi James,

    We are sorry but we are unable to replicate the issue at our end. In our test getFormula() method returned the correct formula as expected. Could you please have a look at the following sample that we used for testing purposes and let us know if we are missing something in order to replicate the issue:

    https://codesandbox.io/s/spread-js-starter-00n1q

    Also, please let us know the SpreadJS version you are using along with OS/Browser info so that we could test on a similar environment once.

    Regards

    Sharad

  • Posted 24 September 2019, 9:42 am EST

    Thanks for getting back to me, I’ll take a look at the sample.

    Here are the versions, SpreadJS I have tried on 12.2.4 and 12.0.10. The browser is jxbrowser version 6.23 running in java 8.

  • Posted 24 September 2019, 11:45 am EST

    Figured out what the problem is.

    When getting the cell we used:

    var cell = getWorkBook().getActiveSheet().getCell(parts[2], parts[1]);

    parts[1] and parts[2] are strings.

    We changed the call to:

    var cell = getWorkBook().getActiveSheet().getCell(parseInt(parts[2]), parseInt(parts[1]));

    and both forms of get formula started working.

    Looking at the cell, I noticed when using strings, row and column were strings in the cell, when using integers, row and column are numbers. Not sure why this would cause the cells referenced in the formula to be strange but it does (it is getting the correct formula.)

    Thanks for looking in to this.

  • Posted 25 September 2019, 12:32 am EST

    We are glad that the issue has been resolved. Thank you for notifying us about the same.

Need extra support?

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

Learn More

Forum Channels