This is a migrated thread and some comments may be shown as answers.

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

3 Answers 494 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 2
Iron
Christopher asked on 19 Jun 2017, 09:38 PM

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.

3 Answers, 1 is accepted

Sort by
0
Christopher
Top achievements
Rank 2
Iron
answered on 19 Jun 2017, 09:46 PM

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;
}
0
Veselin Tsvetanov
Telerik team
answered on 21 Jun 2017, 01:07 PM
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.
0
Doug
Top achievements
Rank 1
answered on 21 Jun 2017, 01:17 PM
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.
Noe
Top achievements
Rank 1
commented on 20 Apr 2024, 04:06 PM

telerik does not support R1C1
Noe
Top achievements
Rank 1
commented on 20 Apr 2024, 04:07 PM

https://feedback.telerik.com/document-processing/1649321-add-support-for-r1c1-formula-style
Tags
Spreadsheet
Asked by
Christopher
Top achievements
Rank 2
Iron
Answers by
Christopher
Top achievements
Rank 2
Iron
Veselin Tsvetanov
Telerik team
Doug
Top achievements
Rank 1
Share this question
or