-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
31 lines (25 loc) · 863 Bytes
/
Copy pathutils.js
File metadata and controls
31 lines (25 loc) · 863 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
27
28
29
30
31
function alp() {
var alphabet = 'abcdefghijklmnopqrstuvwxyz';
var alpObject = {};
for (var i = 0; i < alphabet.length; i++) {
// アルファベットの各文字に対応する数値を設定
alpObject[alphabet.charAt(i)] = i + 1;
}
return alpObject;
}
function getCellAlp(row, column) {
// アルファベットを配列で用意
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let columnAlphabet = "";
while (column > 0) {
// 0インデックスの調整とアルファベットへの変換
column--;
columnAlphabet = alphabet.charAt(column % 26) + columnAlphabet;
column = Math.floor(column / 26);
}
// アルファベットと行番号を組み合わせて返す
return columnAlphabet + row;
// 使用例
// const cellAddress = getCellAlp(2, 3); // "C2"
// Logger.log(cellAddress); // 出力: "C2"
}