line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Sheet; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
5
|
use Array; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
5
|
use Excel::Cell; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(Object); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
469
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my ( $pkg, @config ) = @_; |
10
|
0
|
|
|
|
|
|
my $sheet = { |
11
|
|
|
|
|
|
|
name => 'no name', |
12
|
|
|
|
|
|
|
cells => Array->new( Array->new ), |
13
|
|
|
|
|
|
|
row_count => 0, |
14
|
|
|
|
|
|
|
col_count => 0, |
15
|
|
|
|
|
|
|
@config, |
16
|
|
|
|
|
|
|
}; |
17
|
0
|
|
|
|
|
|
return bless $sheet, $pkg; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
|
sub row_count { return shift->{row_count}; } |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
0
|
|
sub col_count { return shift->{col_count}; } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub name { |
25
|
0
|
|
|
0
|
0
|
|
my ( $self, $new_val ) = @_; |
26
|
0
|
0
|
|
|
|
|
if ( defined $new_val ) { |
27
|
0
|
|
|
|
|
|
$self->{name} = $new_val; |
28
|
0
|
|
|
|
|
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
0
|
|
|
|
|
|
return $self->{name}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get { |
36
|
0
|
|
|
0
|
0
|
|
my ( $self, $row, $col ) = @_; |
37
|
0
|
0
|
|
|
|
|
if ( $col =~ /^[A-Za-z]+$/ ) { |
38
|
0
|
|
|
|
|
|
$col = _letter_to_num($col); |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
return $self->{cells}->[ $row - 1 ][ $col - 1 ]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _letter_to_num { |
44
|
0
|
|
|
0
|
|
|
my $str = shift; |
45
|
0
|
|
|
|
|
|
my $letters = Array->new( split //, uc($str) ); |
46
|
0
|
|
|
|
|
|
my $res = 0; |
47
|
0
|
|
|
|
|
|
for ( my $i = ( $letters->size ) - 1 ; $i >= 0 ; $i-- ) { |
48
|
0
|
|
|
|
|
|
$res += |
49
|
|
|
|
|
|
|
( ( ord( $letters->[$i] ) - ord('A') + 1 ) * |
50
|
|
|
|
|
|
|
( 26**( $letters->size - $i - 1 ) ) ); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
return $res; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |