A spreadsheet labels its columns with letters instead of digits: A is column 1, Z is 26, then it rolls over to AA for 27, AZ for 52, BA for 53, all the way to ZZ (702) and AAA (703). It looks like counting in base-26 with letters for digits, but there is a catch — there is no zero. The letters run A=1 to Z=26 with nothing standing for zero, which makes this a bijective base-26 system (see bijective numeration). You will convert both directions, packaged on one object as excelColumnNumber = { toNumber, toTitle }.
excelColumnNumber.toNumber(title) // column title string -> integer (1-based)
excelColumnNumber.toTitle(n) // integer (n >= 1) -> column title string
toTitle is the exact inverse of toNumber: toNumber(toTitle(n)) returns n.
excelColumnNumber.toNumber('A'); // 1
excelColumnNumber.toNumber('Z'); // 26
excelColumnNumber.toNumber('AA'); // 27
excelColumnNumber.toNumber('ZZ'); // 702
excelColumnNumber.toTitle(1); // 'A'
excelColumnNumber.toTitle(26); // 'Z'
excelColumnNumber.toTitle(27); // 'AA'
excelColumnNumber.toTitle(703); // 'AAA'
A=1 to Z=26, and 26 is a single letter Z, not a carry into two letters. This is what makes the system bijective base-26 rather than ordinary base-26.A–Z. toNumber may assume its input is a valid, non-empty uppercase title; you do not need to reject bad input.toTitle domain — n is always 1 or greater. There is no column 0 and no negative column.toNumber(toTitle(n)) must equal n for every n >= 1. Build both functions yourself; no libraries.