end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

Excel::Writer::XLSX::Utility for perlで excelのA1形式座標←→R1C1形式座標の変換

Math::BaseCalc かと思ったら、Excel::Writer::XLSX::Utility を使うようです。 http://search.cpan.org/perldoc?Excel%3A%3AWriter%3A%3AXLSX

#!/usr/local/bin/perl
use strict;
use warnings;
use utf8;
# use Math::BaseCalc;
use Excel::Writer::XLSX::Utility;
use Data::Dumper;

main();

sub main {

    my $co_a1_org = "C2";
    my ( $row, $col ) = xl_cell_to_rowcol( $co_a1_org );
    print "$co_a1_org -> ($row, $col)\n";

    my @co_r1c1_org = (2,30);
    my $co_a1 = xl_rowcol_to_cell( @co_r1c1_org );
    print "($co_r1c1_org[0], $co_r1c1_org[1]) -> $co_a1\n";
}

↑こう書くと、↓こう変換できます

$ ./foo.pl 
C2 -> (1, 2)
(2, 30) -> AE3