Built-in function to convert column index to range letter format?

4 posts, 0 answers
  1. Christopher
    Christopher avatar
    42 posts
    Member since:
    Jan 2017

    Posted 19 Jun 2017 Link to this post

    Is there a built in function (couldn't find in the documentation) that will convert a column index to it's named range equivalent?

     

    For example convert column 2 to "C", 3 to "D", 27 to "AB", etc.

  2. Christopher
    Christopher avatar
    42 posts
    Member since:
    Jan 2017

    Posted 19 Jun 2017 in reply to Christopher Link to this post

    Still curious if this is built in, however, here's a function for anyone who might be looking:

    /**
     * Translates an column index to its corresponding letter (range format).
     * @param {Number} index - The index of the column.
     * @returns {String}
     */
    var columnIndexToRangeName = function (index) {
        var dividend = index + 1;
        var name = '';
        var modulo;
        while (dividend > 0) {
            modulo = (dividend - 1) % 26;
            name = String.fromCharCode(65 + modulo) + name;
            dividend = Math.round((dividend - modulo) / 26);
        }
        return name;
    }
  3. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1201 posts

    Posted 21 Jun 2017 Link to this post

    Hello Christopher,

    The Spreadsheet widget does not expose a dedicated function, that would allow you to convert column index to its letter representation. The suggested custom implementation, however, is a viable approach when such is needed.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Doug
    Doug avatar
    10 posts
    Member since:
    Mar 2014

    Posted 21 Jun 2017 Link to this post

    Kendo spreadsheet supports row column notation, also known as "R1C1" notation.  So the range "C3:D8" is the same as "R3C3:R8C4", which is easier to determine programmatically.
Back to Top