Quantcast
Channel: プログラミング
Viewing all articles
Browse latest Browse all 8686

■ - polysan_開発メモ

$
0
0
defcolumn_number_to_name(n):
    """列番号をExcelのアルファベット形式に変換"""
    result = ""
    whilen>0:
        n, remainder = divmod(n - 1, 26)
        result = chr(65 + remainder) + result
    returnresult

# 列番号(1始まり)を受け取ります。
# divmod 関数で列番号を26で割った商と余りを取得します。
# アルファベット(A-Z)のASCIIコードに基づいて余りを文字に変換します。
# 商が0になるまで繰り返します。
# これにより、任意の列番号をExcelの列名に変換できます。たとえば:

# 1 → A
# 26 → Z
# 27 → AA
# 28 → AB

Viewing all articles
Browse latest Browse all 8686

Latest Images

Trending Articles



Latest Images