开发者

Convert number to base26 column string for excel. lang perl [duplicate]

开发者 https://www.devze.com 2023-01-06 01:38 出处:网络
This question already has answers here: Closed 12 year开发者_运维问答s ago. Possible Duplicate: How to convert a column number (eg. 127) into an excel column (eg. AA)
This question already has answers here: Closed 12 year开发者_运维问答s ago.

Possible Duplicate:

How to convert a column number (eg. 127) into an excel column (eg. AA)

How convert number to base26 column string for excel. lang perl


Number::Latin


If it's something quick and dirty, the following sub may be useful.

sub column2base26 {

    my $column = shift;
    die "Column $column must be positive" unless $column > 0;

    my $string = 'A';
    $string++ for 2..$column;
    return $string;
}

print column2base26($_), "\n" foreach (23, 15, 333);

# Output:
# W
# O
# LU
0

精彩评论

暂无评论...
验证码 换一张
取 消