| 1 | package NG::Excel::Sheet; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use NG::Array; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use NG::Excel::Cell; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use base qw(NG::Object); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 9 | 0 | my ( $pkg, @config ) = @_; | |||||||||
| 10 | 0 | my $sheet = { | |||||||||
| 11 | name => 'no name', | ||||||||||
| 12 | cells => NG::Array->new( NG::Array->new ), | ||||||||||
| 13 | row_count => 0, | ||||||||||
| 14 | col_count => 0, | ||||||||||
| 15 | @config, | ||||||||||
| 16 | }; | ||||||||||
| 17 | 0 | return bless $sheet, $pkg; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub row_count { return shift->{row_count}; } | ||||||||
|
Subroutine
row_count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub col_count { return shift->{col_count}; } | ||||||||
|
Subroutine
col_count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub name { | ||||||||
|
Subroutine
name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 25 | 0 | my ( $self, $new_val ) = @_; | |||||||||
| 26 | 0 | ▶ | if ( defined $new_val ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | $self->{name} = $new_val; | |||||||||
| 28 | 0 | return $self; | |||||||||
| 29 | } | ||||||||||
| 30 | else { | ||||||||||
| 31 | 0 | return $self->{name}; | |||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub get { | ||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 36 | 0 | my ( $self, $row, $col ) = @_; | |||||||||
| 37 | 0 | ▶ | if ( $col =~ /^[A-Za-z]+$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | $col = _letter_to_num($col); | |||||||||
| 39 | } | ||||||||||
| 40 | 0 | return $self->{cells}->[ $row - 1 ][ $col - 1 ]; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub _letter_to_num { | ||||||||
|
Subroutine
_letter_to_num: not called CC=2 SCAR=17.9
| |||||||||||
| 44 | 0 | my $str = shift; | |||||||||
| 45 | 0 | my $letters = NG::Array->new( split //, uc($str) ); | |||||||||
| 46 | 0 | my $res = 0; | |||||||||
| 47 | 0 | ▶ | for ( my $i = ( $letters->size ) - 1 ; $i >= 0 ; $i-- ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 1; | |||||||||