Branch Coverage

blib/lib/Spreadsheet/Read.pm
Criterion Covered Total %
branch 384 514 74.7


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} ? :
189 1 62 if ref $_[0] eq 'Spreadsheet::Read'
190 2 61 unless my $type = _parser(shift())
191 8 53 if ($can{$type} =~ /^!\s*(.*)/)
201 2 2 wantarray ? :
206 1 15696 if ref $_[0] eq 'Spreadsheet::Read'
208 4 15693 unless defined $c and $c > 0
222 1 15494 if ref $_[0] eq 'Spreadsheet::Read'
224 4 15489 unless defined $c and defined $r and $c > 0 and $r > 0
230 16 588 if ref $_[0] eq 'Spreadsheet::Read'
231 4 600 unless my($cc, $r) = uc($_[0] or '') =~ /^([A-Z]+)([0-9]+)$/
242 7 3 ref $_[0] eq 'Spreadsheet::Read' ? :
1 9 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
243 2 7 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
244 0 7 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
245 1 6 unless my $row = shift()
246 2 4 unless $row > 0 and $row <= $sheet->{'maxrow'}
253 7 3 ref $_[0] eq 'Spreadsheet::Read' ? :
1 9 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
254 2 7 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
255 0 7 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
256 1 6 unless my $row = shift()
257 2 4 unless $row > 0 and $row <= $sheet->{'maxrow'}
264 0 33 ref $_[0] eq 'Spreadsheet::Read' ? :
3 30 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
265 4 26 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
266 21 5 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
277 2 21 unless $book and $sheet
280 15 1 if $sheet =~ /^[0-9]+$/ and $sheet >= 1 and $sheet <= $book->[0]{'sheets'}
282 1 5 if exists $book->[0]{'sheet'}{$sheet}
284 1 5 if $book->[$idx]{'label'} eq $sheet
295 0 227 unless $ref->[0]{'sheets'}
301 212 15 if ($os or $oc)
305 7 247 unless $ss->{'maxrow'} and $ss->{'maxcol'}
309 14738 1898 if ($rc)
310 8857 5881 unless defined $ss->{'cell'}[$col][$row]
311 458 5423 if $os & 2
312 308 5573 if $os & 1
313 4417 1464 if (length $ss->{'cell'}[$col][$row])
314 653 3764 if $col > $mc
315 1404 3013 if $row > $mr
318 7560 219 if ($cl)
320 1327 6233 unless defined $ss->{$cell}
321 558 5675 if $os & 2
322 204 6029 if $os & 1
323 4757 1476 if (length $ss->{$cell})
324 36 4721 if $col > $mc
325 138 4619 if $row > $mr
331 141 106 unless $oc and $mc < $ss->{'maxcol'} || $mr < $ss->{'maxrow'}
335 181 62 if $rc
336 20 223 if $oa
337 50 193 unless $cl
345 64 0 if $cl
346 64 0 if $rc
347 0 64 if $oa
355 1 226 if ($opt->{'pivot'})
358 0 0 unless $ss->{'maxrow'} or $ss->{'maxcol'}
359 0 1 $ss->{'maxrow'} > $ss->{'maxcol'} ? :
364 171 0 if $opt->{'rc'}
367 171 0 if $opt->{'cells'}
380 892 850 unless defined $clr
381 0 850 if $clr eq '#000000'
382 0 850 if $clr =~ /^#[0-9a-fA-F]+$/
383 382 468 if $clr == 0 or $clr == 32767
390 0 1526 unless defined $p
391 0 1526 if $p == 32767
392 892 634 if $p == 0 and not defined $bg
393 216 418 if $p == 1
394 418 0 if $bg < 8 or $bg > 63
399 3 276 unless my $txt = shift()
402 221 55 if (@_)
403 20 201 if (ref $_[0] eq 'HASH') { }
201 0 elsif (@_ % 2 == 0) { }
407 230 46 unless exists $opt{'rc'}
408 241 35 unless exists $opt{'cells'}
409 247 29 unless exists $opt{'attr'}
410 180 96 unless exists $opt{'clip'}
411 171 105 unless exists $opt{'strip'}
412 273 3 unless exists $opt{'dtfmt'}
415 7 269 defined $opt{'debug'} ? :
416 7 269 if $debug > 4
424 20 256 ref($txt) =~ /GLOB|IO/ ? :
426 1 255 $txt =~ /\0/ ? :
20 256 $io_ref ? :
427 245 31 $io_ref || $io_fil ? :
429 11 265 if $io_fil and not -s $txt
430 5 260 if $io_ref and eof $txt
432 27 233 $opt{'parser'} ? :
106 154 if ($opt{'parser'} ? $_parser eq 'csv' : $io_fil && $txt =~ /\.(csv)$/i)
433 0 106 unless $can{'csv'}
435 93 12 $io_fil ? :
1 105 defined $opt{'label'} ? :
437 0 106 if $debug
466 13 93 if defined $opt{'sep'}
467 13 93 if defined $opt{'quote'}
468 0 106 if $debug > 8
470 94 12 if ($io_fil) { }
10 2 elsif ($io_ref) { }
1 1 elsif (ref $txt eq 'SCALAR') { }
1 0 elsif ($txt =~ /[\r\n,;]/) { }
471 87 7 unless (defined $opt{'quote'} and defined $opt{'sep'})
472 0 87 unless open $in, '<', $txt
475 3 84 defined $opt{'quote'} ? :
479 3 56 $l1 =~ /\w\t[\w,]/ ? :
1 59 $l1 =~ /\w,[\w,]/ ? :
0 60 $l1 =~ /\w;[\w;]/ ? :
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'} ? :
489 0 94 unless open $in, '<', $txt
495 0 1 unless open $in, '<', $txt
498 0 1 unless open $in, '<', \$txt
505 0 106 if $debug > 1
510 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})
517 0 413 unless my(@row) = @$row
520 123 290 if @row > $data[1]{'maxcol'}
524 2235 192 if $opt{'rc'}
525 2235 192 if $opt{'cells'}
526 0 2427 if $opt{'attr'}
529 0 106 unless $csv->eof
533 90 644 unless defined $_
538 29 125 if ($io_txt)
539 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))) { }
547 0 1 unless $can{'xls'}
549 1 0 if ($can{'ios'}) { }
558 0 1 unless open $io_ref, '<', $tmpfile
565 0 0 unless $can{'xlsx'}
567 0 0 if ($can{'ios'}) { }
576 0 0 unless open $io_ref, '<', $tmpfile
581 6 148 $opt{'parser'} ? :
75 51 if ($opt{'parser'} ? $_parser =~ /^xlsx?$/ : $io_fil && $txt =~ /\.(xlsx?)$/i && ($_parser = $1))
583 44 31 $_parser =~ /x$/i ? :
584 0 75 unless my $parser = $can{lc $parse_type}
587 0 7 $io_ref ? :
7 68 if $debug
588 0 75 if $opt{'passwd'}
597 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 ? :
602 0 75 unless ($oBook)
607 0 75 if $debug > 8
640 44 0 $can{'xlsx'} =~ /::XLSX$/ ? :
44 31 $parse_type eq 'XLSX' ? :
645 7 68 if $debug
652 6 115 if $opt{'clip'} and not defined $oWkS->{'Cells'}
664 0 115 unless defined $sheet{'label'}
665 110 5 if exists $oWkS->{'MinRow'}
666 110 5 if exists $oWkS->{'MaxRow'}
667 110 5 if exists $oWkS->{'MinCol'}
668 110 5 if exists $oWkS->{'MaxCol'}
674 107 8 unless $oWkS->get_merged_areas
676 15 100 if $debug
677 7 108 if (defined $active_sheet)
679 7 0 defined $oWkS->{'_SheetNo'} ? :
680 1 6 if $sheet_no eq $active_sheet
697 110 5 if (exists $oWkS->{'MinRow'})
700 91 19 if ($opt{'clip'})
704 1207 1701 unless my $oWkC = $oWkS->{'Cells'}[$r][$c]
705 0 1701 unless defined(my $val = $oWkC->{'Val'})
706 22 1679 if $val eq ''
707 415 1264 if $r > $mr
708 296 1383 if $c > $mc
715 1330 1802 unless my $oWkC = $oWkS->{'Cells'}[$r][$c]
718 0 1802 if (defined $val and my $enc = $oWkC->{'Code'})
719 0 0 if $enc eq 'ucs2'
722 1778 24 if $opt{'rc'}
726 952 850 if ($FmT) { }
727 130 822 unless (ref $FmT)
737 5880 4932 unless exists $FmT->{$attr}
739 980 822 unless exists $FmT->{'Fill'}
740 980 822 unless exists $FmT->{'Font'}
742 1672 130 unless (defined $fmt)
745 188 1484 $FmT->{'FmtIdx'} ? :
747 370 1432 if ($oWkC->{'Type'} eq 'Numeric')
756 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]*$]
760 102 249 if $FmT->{'FmtIdx'} == 9 or $FmT->{'FmtIdx'} == 10 or defined $fmt and $fmt =~ /^0+\.0+%$/
762 280 1522 if defined $fmt
765 5 1771 $FmT && exists $def_fmt{$FmT->{'FmtIdx'}} ? :
1776 0 defined $val ? :
1776 26 if $opt{'cells'}
767 1526 276 if ($opt{'attr'})
771 106 1420 $FmT->{'FmtIdx'} ? :
772 68 1458 if $fmi
804 88 321 unless defined $_
808 0 115 if ($sheet{'label'} eq '-- unlabeled --') { }
818 49 28 $io_fil ? :
2 77 $opt{'parser'} ? :
46 33 if ($opt{'parser'} ? _parser($opt{'parser'}) eq 'sc' : ($io_fil ? $txt =~ /\.sc$/ : $txt =~ /^# .*SquirrelCalc/))
822 2 44 if ($io_ref) { }
42 2 elsif ($io_fil) { }
829 0 42 unless open my $sc, '<', $txt
833 0 46 unless $txt =~ /\S/
834 0 46 defined $opt{'label'} ? :
860 46 13432 if (/^dimension.*of ([0-9]+) rows.*of ([0-9]+) columns/i)
864 9890 3542 unless s/^r([0-9]+)c([0-9]+)\s*=\s*//
866 2714 828 if (/.* \{(.*)}$/ or /"(.*)"/)
868 2360 354 if $opt{'rc'}
869 2714 0 if $opt{'cells'}
870 236 2478 if $opt{'attr'}
877 40 320 unless defined $_
882 0 33 $opt{'parser'} ? :
7 26 if ($opt{'parser'} ? _parser($opt{'parser'}) eq 'sxc' : $txt =~ /^<\?xml/ || -f $txt)
884 7 0 unless $can{'sxc'}
885 0 0 if ref $txt
891 0 0 if ($txt =~ /\.(sxc|ods)$/i) { }
0 0 elsif ($txt =~ /\.xml$/i) { }
0 0 elsif (not $txt =~ /^<\?xml/i and -f $txt) { }
892 0 0 if $debug
893 0 0 unless $sxc = Spreadsheet::ReadSXC::read_sxc($txt, $sxc_options)
896 0 0 if $debug
897 0 0 unless $sxc = Spreadsheet::ReadSXC::read_xml_file($txt, $sxc_options)
902 0 0 if $debug
903 0 0 unless open my $f, '<', $txt
908 0 0 if not $sxc and $txt =~ /^<\?xml/i
910 0 0 if $debug > 8
911 0 0 if ($sxc)
931 0 0 ref $sxc eq 'HASH' ? :
945 0 0 if $debug
947 0 0 unless my(@row) = @{$sheet[$r];}
949 0 0 unless defined(my $val = $row[$c])
951 0 0 if $C > $sheet{'maxcol'}
953 0 0 if $opt{'rc'}
954 0 0 if $opt{'cells'}
955 0 0 if $opt{'attr'}
959 0 0 unless defined $_
961 0 0 if $debug
975 0 2 unless my $r = ReadData(@_)
977 0 2 unless $book and ref $book eq 'ARRAY' || ref $book eq 'Spreadsheet::Read' and $book->[0]{'sheets'}
982 0 2 unless ($c1->{'parsers'})
989 2 0 if $p->{'type'} eq $c2->{'type'} and $p->{'parser'} eq $c2->{'parser'}
990 0 2 unless (defined $pidx)
1026 28 0 if @id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/
1028 27 0 if @id and $id[0] and exists $$sheet{$id[0]}
1035 3 0 if @id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/
1036 5 0 if (@id and $id[0] and exists $$sheet{$id[0]})
1054 1 0 if $_[0] =~ /::/
1059 24 0 if $_[0] =~ /::/
1064 21 0 if $_[0] =~ /::/
1070 1 1 if defined $label
1082 3 1 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1090 3 1 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1097 3 1 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}
1105 3 1 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}