getColumn returns unexpected results

Posted by: brian.ploe on 11 January 2024, 7:00 am EST

    • Post Options:
    • Link

    Posted 11 January 2024, 7:00 am EST - Updated 11 January 2024, 7:05 am EST

    Can anyone please tell me why I can’t use getColumn() and getRow() on a cell I retrieved by name?

    The screenshot included shows exactly the issue I am having.

    The internals seem to be tracking the column and row just fine but the function outputs don’t match.

  • Posted 11 January 2024, 7:09 am EST

    Nevermind.

    It seems I have to use a.getExpression().row and a.getExpression().column.

    But why?

    What is the purpose of getRow() and getColumn()?

  • Posted 11 January 2024, 9:59 pm EST

    Hi,

    The getRow and getColumn methods in the NameInfo object return the base row and base column, respectively. The base row and column are used when relative cell references are used in an expression.

    For example, if you have defined a custom name using sheet.addCustomName(“customName”, “=b2”, 0, 0) where the base row and column are both set to 0. When you use this custom name in cell C3, it will refer to cell d4 not b2. This is because B2 was 1 cell away from both the base row and column, so when you apply the custom name in cell C3, the formula becomes “=d4” (1 cell away from C3 both row-wise and column-wise).

    In your case, the reason getColumn() is returning zero because base column was set to zero at the time of defining the custom name.

    References:

    getRow: https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Sheets.NameInfo#getrow

    getColumn: https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Sheets.NameInfo#getcolumn

    Cell References:

    https://developer.mescius.com/spreadjs/docs/formulareference/formulaoverview/cellreferences

    Best regards,

    Ankit

  • Posted 12 January 2024, 2:57 am EST

    Understood. Thanks for taking the time to reply :slight_smile:

Need extra support?

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

Learn More

Forum Channels