| 1 | package Data::Grid::Excel; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.014; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Spreadsheet::ParseExcel; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | extends 'Data::Grid'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Data::Grid::Excel - Excel (original OLE format) driver for Data::Grid | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 VERSION | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Version 0.06 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 METHODS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head2 new | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | has _proxy => ( | |||||||||||||||||||||||||||
| 33 | is => 'rwp', | ||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 37 | 0 | my ($self, $options) = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my $driver = Spreadsheet::ParseExcel->new(%$options); | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | $driver->parse($self->fh) or Carp::croak($driver->error); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | my ($self, $p) = @_; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $options = ref $p->{options} eq 'HASH' ? $p->{options} : {}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | $self->_set__proxy($self->_init($options)); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head2 tables | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub tables { | ||||||||||||||||||||||||||
|
Subroutine
tables: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | my $p = $self->_proxy; | |||||||||||||||||||||||||||
| 59 | 0 | my $tc = $self->table_class; | |||||||||||||||||||||||||||
| 60 | 0 | my @ws = $p->worksheets; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my @tables; | |||||||||||||||||||||||||||
| 63 | 0 | for my $i (0..$#ws) { | |||||||||||||||||||||||||||
| 64 | 0 | my %p = $self->table_params($i); | |||||||||||||||||||||||||||
| 65 | 0 | push @tables, $tc->new(%p, proxy => $ws[$i]); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # do this for overload | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | wantarray ? @tables : \@tables; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head2 table_class | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | has '+table_class' => ( | |||||||||||||||||||||||||||
| 77 | default => 'Data::Grid::Excel::Table', | ||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head2 row_class | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | has '+row_class' => ( | |||||||||||||||||||||||||||
| 85 | default => 'Data::Grid::Excel::Row', | ||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head2 cell_class | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | has '+cell_class' => ( | |||||||||||||||||||||||||||
| 93 | default => 'Data::Grid::Excel::Cell', | ||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | package Data::Grid::Excel::Table; | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 1 | extends 'Data::Grid::Table'; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub rewind { | ||||||||||||||||||||||||||
|
Subroutine
rewind: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 0 | $_[0]->_set_cursor($_[0]->_offset); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 108 | 0 | my $cursor = $self->cursor; | |||||||||||||||||||||||||||
| 109 | 0 | my ($minr, $maxr) = $self->proxy->row_range; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | return unless $maxr - $minr > 0 and $cursor + $minr <= $maxr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$maxr - $minr > 0 and $cursor + $minr <= $maxr
MC/DC0%0/2
$maxr - $minr > 0 and $cursor + $minr <= $maxr
$maxr - $minr > 0
$cursor + $minr <= $maxr
Truth table0%0/3
A and B
A= $maxr - $minr > 0B= $cursor + $minr <= $maxr
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | $self->_set_cursor($cursor + 1); | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | # only bother with this if there is a caller | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $self->parent->row_class->new($self, $cursor, $minr + $cursor) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | if defined wantarray; | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | package Data::Grid::Excel::Row; | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 1 | extends 'Data::Grid::Row'; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub cells { | ||||||||||||||||||||||||||
|
Subroutine
cells: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 127 | 0 | my ($self, $flatten) = @_; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $p = $self->parent; | |||||||||||||||||||||||||||
| 130 | 0 | my $class = $p->parent->cell_class; | |||||||||||||||||||||||||||
| 131 | 0 | my $row = $p->proxy; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | my ($minc, $maxc) = $row->col_range; | |||||||||||||||||||||||||||
| 134 | 0 | my @cells; | |||||||||||||||||||||||||||
| 135 | 0 | ▶ | for (my $c = 0; $c <= $maxc - $minc; $c++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | my $cell = $row->get_cell($self->proxy, $c); | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | push @cells, $flatten ? $cell->value : $class->new($self, $c, $cell); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | # do this for overload | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | wantarray ? @cells : \@cells; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | package Data::Grid::Excel::Cell; | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 1 | extends 'Data::Grid::Cell'; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub value { | ||||||||||||||||||||||||||
|
Subroutine
value: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $_[0]->proxy->value if defined $_[0]->proxy; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub literal { | ||||||||||||||||||||||||||
|
Subroutine
literal: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | $_[0]->proxy->unformatted if defined $_[0]->proxy; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | Dorian Taylor, C<< <dorian at cpan.org> >> | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =over 4 | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =item | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | L<Data::Grid> | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =item | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | L<Spreadsheet::ReadExcel> | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =back | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | Copyright 2010-2018 Dorian Taylor. | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | Licensed under the Apache License, Version 2.0 (the "License"); you | ||||||||||||||||||||||||||||
| 181 | may not use this file except in compliance with the License. You may | ||||||||||||||||||||||||||||
| 182 | obtain a copy of the License at | ||||||||||||||||||||||||||||
| 183 | L<http://www.apache.org/licenses/LICENSE-2.0>. | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 186 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 187 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||||||||||||||||||||||||||
| 188 | implied. See the License for the specific language governing | ||||||||||||||||||||||||||||
| 189 | permissions and limitations under the License. | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =cut | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 1 | 1; # End of Data::Grid::Excel | |||||||||||||||||||||||||||