-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgetColumnPositionByLetter.ts
More file actions
26 lines (23 loc) · 1016 Bytes
/
getColumnPositionByLetter.ts
File metadata and controls
26 lines (23 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { IllegalArgumentException } from "../../exception";
import { getColumnIndexByLetter } from "./getColumnIndexByLetter";
/**
* Converts a column letter (or combination of letters) into a column position.
*
* @param {string} letter - The column label (e.g., `'A'`, `'B'`, ..., `'AA'`).
* @returns {number | null} The corresponding column position.
* @throws {@link IllegalArgumentException}
* @see {@link getColumnLetterByPosition}
* @see {@link getColumnLetterByIndex}
* @see {@link GoogleAppsScript.Spreadsheet.Sheet|Sheet}
* @see [Class Sheet](https://developers.google.com/apps-script/reference/spreadsheet/sheet)
* @since 1.0.0
* @version 1.1.0
* @environment `Google Apps Script`, `Browser`
*/
export function getColumnPositionByLetter(letter: string): number | null {
if (arguments.length === 0) {
throw new IllegalArgumentException();
}
const index = getColumnIndexByLetter(letter);
return index ? index + 1 : null;
}