How can I convert row/col to A1?

Posted by: brian.ploe on 21 June 2021, 4:03 pm EST

    • Post Options:
    • Link

    Posted 21 June 2021, 4:03 pm EST

    SpreadJS got me used to thinking of everything as row and column numbers (base 0) in javascript. I need to update a custom name that was imported form an excel sheet and it looks like I need to drop the custom name and re-add it.

    When I do addCustomName it only seems to work with A1 references. I’d rather not have to write additional code just to figure out the A1 reference when everything else I’ve worked on up to this point was fine with a row and column number.

    Is there a converter in SpreadJS that will do this for me? For instance, if I specify row 0 and column 0 is there a function that will spit out “A1”?

    Am I updating the custom name correctly? There is no way to update an existing one so it has to be dropped and recreated?

    Thanks.

  • Posted 22 June 2021, 6:12 am EST

    Hi Brian,

    For this, you may use the ranegsToFormula method. Please refer to the following code snippet and let us know if you face any issues.

    
    let range = new GC.Spread.Sheets.CellRange(spread.getActiveSheet(), 0, 0, 1, 1);
    var rangesStr = GC.Spread.Sheets.CalcEngine.rangesToFormula([range]);
    console.log(rangesStr);
    
    

    API References:

    rangesToFormula: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.CalcEngine~rangesToFormula.html

    Regards

    Avinash

  • Posted 28 June 2021, 2:42 pm EST

    Thank you. This does what I need.

Need extra support?

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

Learn More

Forum Channels