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
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
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
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.