| 1 | package Spreadsheet::ParseExcel::Stream; | ||||||||||||
| 2 | |||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 8 | our $VERSION = '0.11'; | |||||||||||
| 7 | |||||||||||||
| 8 | 8 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=8 SCAR=25.1
Pod
documented
| |||||||||||||
| 9 | |||||||||||||
| 10 | 8 | my ($class, $file, $opts) = @_; | |||||||||||
| 11 | 8 | ▶ | $opts ||= {}; | ||||||||||
|
Condition100%2/2
$opts ||= {}
MC/DC100%1/1
$opts ||= {}
$opts
Truth table100%2/2
A
A= $opts
| |||||||||||||
| 12 | 8 | my $type = $opts->{Type}; | |||||||||||
| 13 | |||||||||||||
| 14 | 8 | ▶ | if ($type) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 15 | 0 | ▶ | return $class->xls($file, $opts) if $type =~ /^xls$/i; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | 0 | ▶ | return $class->xlsx($file, $opts) if $type =~ /^xlsx$/i; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | 0 | die "Can not parse file $file of type $type"; | |||||||||||
| 18 | } | ||||||||||||
| 19 | |||||||||||||
| 20 | 8 | ▶ | open(my $fh, "<", $file) or die "Failed to open $file: $!"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 8 | my $cnt = read($fh, my $pk, 4); | |||||||||||
| 22 | 8 | close $fh; | |||||||||||
| 23 | 8 | ▶ | die "Unable to read header from $file" unless $cnt == 4; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | |||||||||||||
| 25 | 8 | ▶ | return $class->xlsx($file, $opts) if $pk eq "PK\003\004"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 26 | 8 | return $class->xls($file, $opts); | |||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 8 | ▶ | sub xls { | ||||||||||
|
Subroutine
xls: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 30 | 8 | my ($class, $file, $opts) = @_; | |||||||||||
| 31 | 8 | require Spreadsheet::ParseExcel::Stream::XLS; | |||||||||||
| 32 | 8 | return Spreadsheet::ParseExcel::Stream::XLS->new($file, $opts); | |||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 0 | ▶ | sub xlsx { | ||||||||||
|
Subroutine
xlsx: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 36 | 0 | my ($class, $file, $opts) = @_; | |||||||||||
| 37 | 0 | require Spreadsheet::ParseExcel::Stream::XLSX; | |||||||||||
| 38 | 0 | return Spreadsheet::ParseExcel::Stream::XLSX->new($file, $opts); | |||||||||||
| 39 | } | ||||||||||||
| 40 | |||||||||||||
| 41 | 8 | 1; | |||||||||||
| 42 | |||||||||||||
| 43 | __END__ | ||||||||||||