Thread Excel Spaltenbuchstaben in Zahl umwandeln (4 answers)
Opened by Kean at 2017-05-15 11:17

Muffi
 2017-05-15 15:11
#186534 #186534
User since
2012-07-18
1465 Artikel
BenutzerIn
[default_avatar]
Sowas in der Art?

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
my @test = qw(A B Z AA AC BA ABC);

sub SIZE_ALPHABET() { scalar (() = 'A'..'Z') }

for my $test (@test) {
        my $num = 0;
        for my $idx (0..length($test) -1) {
                my $char = substr($test, -$idx-1, 1);
                $num += ((ord($char) - ord('A') + 1) * (SIZE_ALPHABET ** $idx));
        }
        
        say "$test = $num";
}
1 + 1 = 10

View full thread Excel Spaltenbuchstaben in Zahl umwandeln