File Coverage

blib/lib/Data/TableReader/Decoder/XLSX.pm
Criterion Covered Total %
statement 10 21 47.6
branch 0 6 0.0
condition 1 6 16.6
subroutine 4 5 80.0
pod 1 1 100.0
total 16 39 41.0


line stmt bran cond sub pod time code
1             package Data::TableReader::Decoder::XLSX;
2             $Data::TableReader::Decoder::XLSX::VERSION = '0.009';
3 1     1   57945 use Moo 2;
  1         8664  
  1         5  
4 1     1   1165 use Carp;
  1         2  
  1         42  
5 1     1   5 use Try::Tiny;
  1         2  
  1         184  
6             extends 'Data::TableReader::Decoder::Spreadsheet';
7              
8             our @xlsx_probe_modules= qw( Spreadsheet::ParseXLSX Spreadsheet::XLSX );
9             our $default_xlsx_module;
10             sub default_xlsx_module {
11 1   33 1 1 1261 $default_xlsx_module ||=
12             Data::TableReader::Decoder::_first_sufficient_module('XLSX parser', \@xlsx_probe_modules);
13             }
14              
15             # ABSTRACT: Access sheets/rows of a modern Microsoft Excel workbook
16              
17              
18             sub _build_workbook {
19 0     0     my $self= shift;
20            
21 0           my $wbook;
22 0           my $f= $self->file_handle;
23 0 0 0       if (ref $f and ref($f)->can('worksheets')) {
24 0           $wbook= $f;
25             } else {
26 0           my $class= $self->default_xlsx_module;
27             # Spreadsheet::XLSX has an incompatible constructor
28 0 0         if ($class->isa('Spreadsheet::XLSX')) {
29 0           $wbook= $class->new($f);
30             } else {
31 0           $wbook= $class->new->parse($f, $self->xls_formatter);
32             }
33             }
34 0 0         defined $wbook or croak "Can't parse file '".$self->file_name."'";
35 0           return $wbook;
36             }
37              
38             1;
39              
40             __END__