Google Sheets: Convert Column Alphabet to Index Number (Kotlin)

Apr 7, 2019
Index to Column Alphabet. A=0, B=1, C=2
object SheetHelper {    fun toColChar0(index: Int): Char {        return (index + 65).toChar()    }    fun toColChar(index: Int): Char {        return toColChar0(index-1)    }    fun toColIndex0(char: Char): Int {        return char.toInt() - 65    }    fun toColIndex(char: Char): Int {        return toColIndex0(char) + 1    }}
val colA = SheetHelper.toColChar0(0)val colB = SheetHelper.toColChar0(1)val col0 = SheetHelper.toColIndex0('A')val col1 = SheetHelper.toColIndex0('B')
val colA = SheetHelper.toColChar(1)val colB = SheetHelper.toColChar(2)val col1 = SheetHelper.toColIndex('A')val col2 = SheetHelper.toColIndex('B')

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.