Skip to content

Instantly share code, notes, and snippets.

@ChrisDobby
Created February 6, 2023 19:08
Show Gist options
  • Save ChrisDobby/0bb4fce64804e9c25f9fdceb59526b95 to your computer and use it in GitHub Desktop.
Save ChrisDobby/0bb4fce64804e9c25f9fdceb59526b95 to your computer and use it in GitHub Desktop.
Spreadsheet programs often use the A1 Reference Style to refer to columns. Given a column name in this style, return its column number.
const colNamesToNumbers = (name: string) => name.split('').reduce((acc, ch) => acc * 26 + ch.charCodeAt(0) - 64, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment