Branch Coverage

blib/lib/Spreadsheet/Read.pm
Criterion Covered Total %
branch 394 528 74.6


line true false branch
153 7 0 if ($can{'dmp'}) { }
162 242 100 unless my $type = shift()
165 1 99 if $type eq 'excel'
166 0 99 if $type eq 'excel2007'
167 1 98 if $type eq 'oo'
168 2 96 if $type eq 'ods'
169 1 95 if $type eq 'openoffice'
170 0 95 if $type eq 'libreoffice'
171 1 94 if $type eq 'perl'
172 0 94 if $type eq 'squirelcalc'
173 93 1 exists $can{$type} ? :
179 2 10 unless ($r)
180 2 0 if @_
193 1 62 if ref $_[0] eq 'Spreadsheet::Read'
194 2 61 unless my $type = _parser(shift())
195 8 53 if ($can{$type} =~ /^!\s*(.*)/)
205 2 2 wantarray ? :
210 1 15696 if ref $_[0] eq 'Spreadsheet::Read'
212 4 15693 unless defined $c and $c > 0
226 1 15494 if ref $_[0] eq 'Spreadsheet::Read'
228 4 15489 unless defined $c and defined $r and $c > 0 and $r > 0
234 16 588 if ref $_[0] eq 'Spreadsheet::Read'
235 4 600 unless my($cc, $r) = uc($_[0] or '') =~ /^([A-Z]+)([0-9]+)$/
246 7 3 ref $_[0] eq 'Spreadsheet::Read' ? :
1 9 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
247 2 7 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
248 0 7 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
249 1 6 unless my $row = shift()
250 2 4 unless $row > 0 and $row <= $sheet->{'maxrow'}
258 7 3 ref $_[0] eq 'Spreadsheet::Read' ? :
1 9 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
259 2 7 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
260 0 7 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
261 1 6 unless my $row = shift()
262 2 4 unless $row > 0 and $row <= $sheet->{'maxrow'}
269 0 33 ref $_[0] eq 'Spreadsheet::Read' ? :
3 30 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
270 4 26 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
271 21 5 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
282 2 21 unless $book and $sheet
285 15 1 if $sheet =~ /^[0-9]+$/ and $sheet >= 1 and $sheet <= $book->[0]{'sheets'}
287 1 5 if exists $book->[0]{'sheet'}{$sheet}
289 1 5 if $book->[$idx]{'label'} eq $sheet
300 0 227 unless $ref->[0]{'sheets'}
306 212 15 if ($os or $oc)
310 7 247 unless $ss->{'maxrow'} and $ss->{'maxcol'}
314 14738 1898 if ($rc)
315 8857 5881 unless defined $ss->{'cell'}[$col][$row]
316 458 5423 if $os & 2
317 308 5573 if $os & 1
318 4417 1464 if (length $ss->{'cell'}[$col][$row])
319 653 3764 if $col > $mc
320 1404 3013 if $row > $mr
323 7560 219 if ($cl)
325 1327 6233 unless defined $ss->{$cell}
326 558 5675 if $os & 2
327 204 6029 if $os & 1
328 4757 1476 if (length $ss->{$cell})
329 36 4721 if $col > $mc
330 138 4619 if $row > $mr
336 141 106 unless $oc and $mc < $ss->{'maxcol'} || $mr < $ss->{'maxrow'}
340 181 62 if $rc
341 20 223 if $oa
342 50 193 unless $cl
350 64 0 if $cl
351 64 0 if $rc
352 0 64 if $oa
360 1 226 if ($opt->{'pivot'})
363 0 0 unless $ss->{'maxrow'} or $ss->{'maxcol'}
364 0 1 $ss->{'maxrow'} > $ss->{'maxcol'} ? :
369 171 0 if $opt->{'rc'}
372 171 0 if $opt->{'cells'}
385 892 850 unless defined $clr
386 0 850 if $clr eq '#000000'
387 0 850 if $clr =~ /^#[0-9a-fA-F]+$/
388 382 468 if $clr == 0 or $clr == 32767
395 0 1526 unless defined $p
396 0 1526 if $p == 32767
397 892 634 if $p == 0 and not defined $bg
398 216 418 if $p == 1
399 418 0 if $bg < 8 or $bg > 63
404 3 276 unless my $txt = shift()
407 221 55 if (@_)
408 20 201 if (ref $_[0] eq 'HASH') { }
201 0 elsif (@_ % 2 == 0) { }
412 230 46 unless exists $opt{'rc'}
413 241 35 unless exists $opt{'cells'}
414 247 29 unless exists $opt{'attr'}
415 180 96 unless exists $opt{'clip'}
416 171 105 unless exists $opt{'strip'}
417 273 3 unless exists $opt{'dtfmt'}
420 7 269 defined $opt{'debug'} ? :
421 7 269 if $debug > 4
429 20 256 ref($txt) =~ /GLOB|IO/ ? :
431 1 255 $txt =~ /\0/ ? :
20 256 $io_ref ? :
432 245 31 $io_ref || $io_fil ? :
434 11 265 if ($io_fil and not -s $txt)
435 5 260 if ($io_ref and eof $txt)
437 27 233 $opt{'parser'} ? :
106 154 if ($opt{'parser'} ? $_parser eq 'csv' : $io_fil && $txt =~ /\.(csv)$/i)
438 0 106 unless $can{'csv'}
440 93 12 $io_fil ? :
1 105 defined $opt{'label'} ? :
442 0 106 if $debug
471 13 93 if defined $opt{'sep'}
472 13 93 if defined $opt{'quote'}
473 0 106 if $debug > 8
475 94 12 if ($io_fil) { }
10 2 elsif ($io_ref) { }
1 1 elsif (ref $txt eq 'SCALAR') { }
1 0 elsif ($txt =~ /[\r\n,;]/) { }
476 87 7 unless (defined $opt{'quote'} and defined $opt{'sep'})
477 0 87 unless open $in, '<', $txt
480 3 84 defined $opt{'quote'} ? :
484 0 56 $l1 =~ /\w\|[\w,]/ ? :
3 56 $l1 =~ /\w\t[\w,]/ ? :
1 59 $l1 =~ /\w,[\w,]/ ? :
0 60 $l1 =~ /\w;[\w;]/ ? :
0 60 $l1 =~ /["0-9]\|["0-9,]/ ? :
0 60 $l1 =~ /["0-9]\t["0-9,]/ ? :
17 60 $l1 =~ /["0-9],["0-9,]/ ? :
10 77 $l1 =~ /["0-9];["0-9;]/ ? :
0 87 defined $opt{'sep'} ? :
496 0 94 unless open $in, '<', $txt
502 0 1 unless open $in, '<', $txt
505 0 1 unless open $in, '<', \$txt
512 0 106 if $debug > 1
517 0 106 unless my $csv = $can{'csv'}->new({%parser_opts, 'sep_char', $data[0]{'sepchar'} = $sep, 'quote_char', $data[0]{'quote'} = $quo, 'keep_meta_info', 1, 'binary', 1, 'auto_diag', 1})
524 0 413 unless my(@row) = @$row
527 123 290 if @row > $data[1]{'maxcol'}
531 2235 192 if $opt{'rc'}
532 2235 192 if $opt{'cells'}
533 0 2427 if $opt{'attr'}
536 0 106 unless $csv->eof
540 90 644 unless defined $_
545 29 125 if ($io_txt)
546 1 28 if ($txt =~ /\A(\376\067\0\043 |\320\317\021\340\241\261\032\341 |\333\245-\0\0\0)/x or $txt =~ /\A.{2080}Microsoft Excel 5.0 Worksheet/ or $txt =~ /\A\x09\x04\x06\x00\x00\x00\x10\x00/) { }
0 28 elsif ($txt =~ m(\APK\003\004.{4,30}(?:\[Content_Types\]\.xml|_rels/\.rels))) { }
3 25 elsif (not $io_ref and $txt =~ /\.xlsx?$/i) { }
554 0 1 unless $can{'xls'}
556 1 0 if ($can{'ios'}) { }
565 0 1 unless (open $io_ref, '<', $tmpfile)
572 0 0 unless $can{'xlsx'}
574 0 0 if ($can{'ios'}) { }
583 0 0 unless (open $io_ref, '<', $tmpfile)
592 6 145 $opt{'parser'} ? :
75 51 if ($opt{'parser'} ? $_parser =~ /^xlsx?$/ : $io_fil && $txt =~ /\.(xlsx?)$/i && ($_parser = $1))
594 44 31 $_parser =~ /x$/i ? :
595 0 75 unless my $parser = $can{lc $parse_type}
598 0 7 $io_ref ? :
7 68 if $debug
599 0 75 if $opt{'passwd'}
608 0 0 $can{'xlsx'} =~ /::XLSX$/ ? :
0 4 $parse_type eq 'XLSX' ? :
44 0 $can{'xlsx'} =~ /::XLSX$/ ? :
44 27 $parse_type eq 'XLSX' ? :
4 71 $io_ref ? :
613 0 75 unless ($oBook)
618 0 75 if $debug > 8
651 44 0 $can{'xlsx'} =~ /::XLSX$/ ? :
44 31 $parse_type eq 'XLSX' ? :
656 7 68 if $debug
663 6 115 if $opt{'clip'} and not defined $oWkS->{'Cells'}
675 0 115 unless defined $sheet{'label'}
676 110 5 if exists $oWkS->{'MinRow'}
677 110 5 if exists $oWkS->{'MaxRow'}
678 110 5 if exists $oWkS->{'MinCol'}
679 110 5 if exists $oWkS->{'MaxCol'}
685 107 8 unless $oWkS->get_merged_areas
687 15 100 if $debug
688 7 108 if (defined $active_sheet)
690 7 0 defined $oWkS->{'_SheetNo'} ? :
691 1 6 if $sheet_no eq $active_sheet
708 110 5 if (exists $oWkS->{'MinRow'})
711 91 19 if ($opt{'clip'})
715 1207 1701 unless my $oWkC = $oWkS->{'Cells'}[$r][$c]
716 0 1701 unless defined(my $val = $oWkC->{'Val'})
717 22 1679 if $val eq ''
718 415 1264 if $r > $mr
719 296 1383 if $c > $mc
726 1330 1802 unless my $oWkC = $oWkS->{'Cells'}[$r][$c]
729 0 1802 if (defined $val and my $enc = $oWkC->{'Code'})
730 0 0 if $enc eq 'ucs2'
733 1778 24 if $opt{'rc'}
737 952 850 if ($FmT) { }
738 130 822 unless (ref $FmT)
748 5880 4932 unless exists $FmT->{$attr}
750 980 822 unless exists $FmT->{'Fill'}
751 980 822 unless exists $FmT->{'Font'}
753 1672 130 unless (defined $fmt)
756 188 1484 $FmT->{'FmtIdx'} ? :
758 370 1432 if ($oWkC->{'Type'} eq 'Numeric')
767 8 362 if $FmT->{'FmtIdx'} == 14 or $FmT->{'FmtIdx'} == 15 or $FmT->{'FmtIdx'} == 16 or $FmT->{'FmtIdx'} == 17 or $FmT->{'FmtIdx'} == 22 or defined $fmt and $fmt =~ m[^[dmy][-\\/dmy]*$]
771 102 249 if $FmT->{'FmtIdx'} == 9 or $FmT->{'FmtIdx'} == 10 or defined $fmt and $fmt =~ /^0+\.0+%$/
773 280 1522 if defined $fmt
776 5 1771 $FmT && exists $def_fmt{$FmT->{'FmtIdx'}} ? :
1776 0 defined $val ? :
1776 26 if $opt{'cells'}
778 1526 276 if ($opt{'attr'})
782 106 1420 $FmT->{'FmtIdx'} ? :
783 68 1458 if $fmi
815 88 321 unless defined $_
819 0 115 if ($sheet{'label'} eq '-- unlabeled --') { }
829 49 25 $io_fil ? :
2 74 $opt{'parser'} ? :
46 30 if ($opt{'parser'} ? _parser($opt{'parser'}) eq 'sc' : ($io_fil ? $txt =~ /\.sc$/ : $txt =~ /^# .*SquirrelCalc/))
833 2 44 if ($io_ref) { }
42 2 elsif ($io_fil) { }
840 0 42 unless open my $sc, '<', $txt
844 0 46 unless $txt =~ /\S/
845 0 46 defined $opt{'label'} ? :
871 46 13432 if (/^dimension.*of ([0-9]+) rows.*of ([0-9]+) columns/i)
875 9890 3542 unless s/^r([0-9]+)c([0-9]+)\s*=\s*//
877 2714 828 if (/.* \{(.*)}$/ or /"(.*)"/)
879 2360 354 if $opt{'rc'}
880 2714 0 if $opt{'cells'}
881 236 2478 if $opt{'attr'}
888 40 320 unless defined $_
893 0 30 $opt{'parser'} ? :
7 23 if ($opt{'parser'} ? _parser($opt{'parser'}) eq 'sxc' : $txt =~ /^<\?xml/ || -f $txt)
895 7 0 unless $can{'sxc'}
896 0 0 if ref $txt
902 0 0 if ($txt =~ /\.(sxc|ods)$/i) { }
0 0 elsif ($txt =~ /\.xml$/i) { }
0 0 elsif (not $txt =~ /^<\?xml/i and -f $txt) { }
903 0 0 if $debug
904 0 0 unless $sxc = Spreadsheet::ReadSXC::read_sxc($txt, $sxc_options)
907 0 0 if $debug
908 0 0 unless $sxc = Spreadsheet::ReadSXC::read_xml_file($txt, $sxc_options)
913 0 0 if $debug
914 0 0 unless open my $f, '<', $txt
919 0 0 if not $sxc and $txt =~ /^<\?xml/i
921 0 0 if $debug > 8
922 0 0 if ($sxc)
942 0 0 ref $sxc eq 'HASH' ? :
956 0 0 if $debug
958 0 0 unless my(@row) = @{$sheet[$r];}
960 0 0 unless defined(my $val = $row[$c])
962 0 0 if $C > $sheet{'maxcol'}
964 0 0 if $opt{'rc'}
965 0 0 if $opt{'cells'}
966 0 0 if $opt{'attr'}
970 0 0 unless defined $_
972 0 0 if $debug
981 5 18 if (not ref $txt and $txt =~ /\.\w+$/)
983 0 5 if open my $fh, '<', $txt
994 0 2 unless my $r = ReadData(@_)
996 0 2 unless $book and ref $book eq 'ARRAY' || ref $book eq 'Spreadsheet::Read' and $book->[0]{'sheets'}
1001 0 2 unless ($c1->{'parsers'})
1008 2 0 if $p->{'type'} eq $c2->{'type'} and $p->{'parser'} eq $c2->{'parser'}
1009 0 2 unless (defined $pidx)
1045 28 0 if @id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/
1047 27 0 if @id and $id[0] and exists $$sheet{$id[0]}
1054 3 0 if @id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/
1055 5 0 if (@id and $id[0] and exists $$sheet{$id[0]})
1073 1 0 if $_[0] =~ /::/
1078 24 0 if $_[0] =~ /::/
1083 21 0 if $_[0] =~ /::/
1089 1 1 if defined $label
1101 3 1 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1109 3 1 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1116 3 1 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}
1124 3 1 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}