Branch Coverage

blib/lib/Spreadsheet/Read.pm
Criterion Covered Total %
branch 423 652 64.8


line true false branch
159 7 0 if ($can{'dmp'}) { }
170 243 177 unless my $type = shift()
172 8 169 $can{'ods'} ? :
174 1 176 if $type eq 'excel'
175 0 176 if $type eq 'excel2007'
176 0 176 if $type eq 'xlsm'
177 1 175 if $type eq 'oo'
179 1 174 if $type eq 'openoffice'
180 0 174 if $type eq 'libreoffice'
181 1 173 if $type eq 'perl'
182 0 173 if $type eq 'squirelcalc'
183 172 1 exists $can{$type} ? :
189 2 11 unless ($r)
190 2 0 if @_
203 1 67 if ref $_[0] eq 'Spreadsheet::Read'
204 2 66 unless my $type = _parser(shift())
205 17 49 if ($can{$type} =~ /^!\s*(.*)/)
215 2 2 wantarray ? :
220 1 15738 if ref $_[0] eq 'Spreadsheet::Read'
222 4 15735 unless defined $c and $c > 0
236 1 15536 if ref $_[0] eq 'Spreadsheet::Read'
238 4 15531 unless defined $c and defined $r and $c > 0 and $r > 0
244 16 604 if ref $_[0] eq 'Spreadsheet::Read'
245 4 616 unless my($cc, $r) = uc($_[0] or '') =~ /^([A-Z]+)([0-9]+)$/
256 7 3 ref $_[0] eq 'Spreadsheet::Read' ? :
1 9 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
257 2 7 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
258 0 7 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
259 1 6 unless my $row = shift()
260 2 4 unless $row > 0 and $row <= $sheet->{'maxrow'}
268 7 3 ref $_[0] eq 'Spreadsheet::Read' ? :
1 9 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
269 2 7 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
270 0 7 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
271 1 6 unless my $row = shift()
272 2 4 unless $row > 0 and $row <= $sheet->{'maxrow'}
279 0 33 ref $_[0] eq 'Spreadsheet::Read' ? :
3 30 unless my $sheet = ref $_[0] eq 'Spreadsheet::Read' ? (shift())->[shift()] : shift()
280 4 26 unless ref $sheet eq 'HASH' and exists $sheet->{'cell'}
281 21 5 unless exists $sheet->{'maxcol'} and exists $sheet->{'maxrow'}
292 2 22 unless $book and $sheet
295 16 1 if $sheet =~ /^[0-9]+$/ and $sheet >= 1 and $sheet <= $book->[0]{'sheets'}
297 1 5 if exists $book->[0]{'sheet'}{$sheet}
299 1 5 if $book->[$idx]{'label'} eq $sheet
310 0 228 unless $ref->[0]{'sheets'}
316 213 15 if ($os or $oc)
320 7 248 unless $ss->{'maxrow'} and $ss->{'maxcol'}
324 14754 1898 if ($rc)
325 8857 5897 unless defined $ss->{'cell'}[$col][$row]
326 458 5439 if $os & 2
327 308 5589 if $os & 1
328 4432 1465 if (length $ss->{'cell'}[$col][$row])
329 656 3776 if $col > $mc
330 1408 3024 if $row > $mr
333 7576 219 if ($cl)
335 1327 6249 unless defined $ss->{$cell}
336 558 5691 if $os & 2
337 204 6045 if $os & 1
338 4772 1477 if (length $ss->{$cell})
339 36 4736 if $col > $mc
340 138 4634 if $row > $mr
346 142 106 unless $oc and $mc < $ss->{'maxcol'} || $mr < $ss->{'maxrow'}
350 181 62 if $rc
351 20 223 if $oa
352 50 193 unless $cl
360 64 0 if $cl
361 64 0 if $rc
362 0 64 if $oa
370 1 227 if ($opt->{'pivot'})
373 0 0 unless $ss->{'maxrow'} or $ss->{'maxcol'}
374 0 1 $ss->{'maxrow'} > $ss->{'maxcol'} ? :
379 171 0 if $opt->{'rc'}
382 171 0 if $opt->{'cells'}
395 892 866 unless defined $clr
396 0 866 if $clr eq '#000000'
397 0 866 if $clr =~ /^#[0-9a-fA-F]+$/
398 382 484 if $clr == 0 or $clr == 32767
405 0 1542 unless defined $p
406 0 1542 if $p == 32767
407 892 650 if $p == 0 and not defined $bg
408 216 434 if $p == 1
409 434 0 if $bg < 8 or $bg > 63
414 3 277 unless my $txt = shift()
417 222 55 if (@_)
418 20 202 if (ref $_[0] eq 'HASH') { }
202 0 elsif (@_ % 2 == 0) { }
422 231 46 unless exists $opt{'rc'}
423 242 35 unless exists $opt{'cells'}
424 247 30 unless exists $opt{'attr'}
425 181 96 unless exists $opt{'clip'}
426 172 105 unless exists $opt{'strip'}
427 274 3 unless exists $opt{'dtfmt'}
428 276 1 unless exists $opt{'merge'}
431 7 270 defined $opt{'debug'} ? :
432 7 270 if $debug > 4
440 20 257 ref($txt) =~ /GLOB|IO/ ? :
442 1 256 $txt =~ /\0/ ? :
20 257 $io_ref ? :
443 246 31 $io_ref || $io_fil ? :
445 11 266 if ($io_fil and not -s $txt)
446 5 261 if ($io_ref and eof $txt)
448 27 234 $opt{'parser'} ? :
106 155 if ($opt{'parser'} ? $_parser eq 'csv' : $io_fil && $txt =~ /\.(csv)$/i)
449 0 106 unless $can{'csv'}
451 93 12 $io_fil ? :
1 105 defined $opt{'label'} ? :
453 0 106 if $debug
482 13 93 if defined $opt{'sep'}
483 13 93 if defined $opt{'quote'}
484 0 106 if $debug > 8
486 94 12 if ($io_fil) { }
10 2 elsif ($io_ref) { }
1 1 elsif (ref $txt eq 'SCALAR') { }
1 0 elsif ($txt =~ /[\r\n,;]/) { }
487 87 7 unless (defined $opt{'quote'} and defined $opt{'sep'})
488 0 87 unless open $in, '<', $txt
491 3 84 defined $opt{'quote'} ? :
495 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'} ? :
507 0 94 unless open $in, '<', $txt
513 0 1 unless open $in, '<', $txt
516 0 1 unless open $in, '<', \$txt
523 0 106 if $debug > 1
528 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})
535 0 413 unless my(@row) = @$row
538 123 290 if @row > $data[1]{'maxcol'}
542 2235 192 if $opt{'rc'}
543 2235 192 if $opt{'cells'}
544 0 2427 if $opt{'attr'}
547 0 106 unless $csv->eof
551 90 644 unless defined $_
556 29 126 if ($io_txt)
557 1 28 if ($txt =~ /\A(\376\067\0\043
0 28 elsif ($txt =~ m(\APK\003\004.{4,30}(?:\[Content_Types\]\.xml|_rels/\.rels))) { }
0 28 elsif ($txt =~ m[\APK\003\004.{9,30}mimetypeapplication\/vnd\.oasis\.opendocument\.spreadsheet]) { }
3 25 elsif (not $io_ref and $txt =~ /\.xls[xm]?$/i) { }
565 0 1 unless $can{'xls'}
567 1 0 if ($can{'ios'}) { }
576 0 1 unless (open $io_ref, '<', $tmpfile)
583 0 0 unless $can{'xlsx'}
585 0 0 if ($can{'ios'}) { }
594 0 0 unless (open $io_ref, '<', $tmpfile)
601 0 0 unless $can{'ods'}
603 0 0 if ($can{'ios'}) { }
612 0 0 unless (open $io_ref, '<', $tmpfile)
621 6 146 $opt{'parser'} ? :
76 51 if ($opt{'parser'} ? $_parser =~ /^(?:xlsx?)$/ : $io_fil && $txt =~ /\.(xls[xm]?)$/i && ($_parser = _parser($1)))
624 44 32 $_parser =~ /x$/i ? :
625 0 76 unless my $parser = $can{lc $parse_type}
629 0 7 $io_ref ? :
7 69 if $debug
630 0 76 if $opt{'passwd'}
639 0 0 $can{'xlsx'} =~ /::XLSX$/ ? :
0 4 $parse_type eq 'XLSX' ? :
44 0 $can{'xlsx'} =~ /::XLSX$/ ? :
44 28 $parse_type eq 'XLSX' ? :
4 72 $io_ref ? :
644 0 76 unless ($oBook)
649 0 76 if $debug > 8
681 44 0 $can{'xlsx'} =~ /::XLSX$/ ? :
44 32 $parse_type eq 'XLSX' ? :
686 0 76 if $debug > 20
687 0 76 if ($parse_type eq 'ODS' and not exists $oBook->{'SheetCount'})
690 0 0 if ($sheets and ref $sheets eq 'ARRAY')
718 0 0 if $#$row > $oBook->{'Worksheet'}[-1]{'MaxCol'}
736 0 0 if --$r > $oBook->{'Worksheet'}[-1]{'MaxRow'}
741 7 69 if $debug
747 0 122 if $debug > 8
749 6 116 if $opt{'clip'} and not defined $oWkS->{'Cells'}
761 0 116 unless defined $sheet{'label'}
762 111 5 if exists $oWkS->{'MinRow'}
763 111 5 if exists $oWkS->{'MaxRow'}
764 111 5 if exists $oWkS->{'MinCol'}
765 111 5 if exists $oWkS->{'MaxCol'}
771 107 9 unless $oWkS->get_merged_areas
773 15 101 if $debug
774 7 109 if (defined $active_sheet)
776 7 0 defined $oWkS->{'_SheetNo'} ? :
777 1 6 if $sheet_no eq $active_sheet
794 111 5 if (exists $oWkS->{'MinRow'})
797 92 19 if ($opt{'clip'})
801 1221 1717 unless my $oWkC = $oWkS->{'Cells'}[$r][$c]
802 0 1717 unless defined(my $val = $oWkC->{'Val'})
803 27 1690 if $val eq ''
804 419 1271 if $r > $mr
805 298 1392 if $c > $mc
812 1339 1818 unless my $oWkC = $oWkS->{'Cells'}[$r][$c]
815 0 1818 if (defined $val and my $enc = $oWkC->{'Code'})
816 0 0 if $enc eq 'ucs2'
819 1794 24 if $opt{'rc'}
823 968 850 if ($FmT) { }
824 130 838 unless (ref $FmT)
834 5880 5028 unless exists $FmT->{$attr}
836 980 838 unless exists $FmT->{'Fill'}
837 980 838 unless exists $FmT->{'Font'}
839 1688 130 unless (defined $fmt)
842 204 1484 $FmT->{'FmtIdx'} ? :
845 0 1818 if lc $oWkC->{'Type'} eq 'float'
846 370 1448 if ($oWkC->{'Type'} eq 'Numeric')
855 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]*$]
859 102 249 if $FmT->{'FmtIdx'} == 9 or $FmT->{'FmtIdx'} == 10 or defined $fmt and $fmt =~ /^0+\.0+%$/
861 296 1522 if defined $fmt
864 5 1787 $FmT && exists $def_fmt{$FmT->{'FmtIdx'}} ? :
1792 0 defined $val ? :
1792 26 if $opt{'cells'}
866 1542 276 if ($opt{'attr'})
870 122 1420 $FmT->{'FmtIdx'} ? :
871 84 1458 if $fmi
899 6 10 if ($opt{'merge'} and $merged and my $p_cell = Spreadsheet::Read::Sheet::merged_from(\%sheet, $c + 1, $r + 1))
903 4 2 if ($cell ne $p_cell)
915 89 325 unless defined $_
919 0 116 if ($sheet{'label'} eq '-- unlabeled --') { }
928 2 74 $opt{'parser'} ? :
0 2 if ($opt{'parser'} ? $_parser =~ /^(ods)$/ : $io_fil && $txt =~ /(ods)$/i && ($_parser = _parser($1)) and not +($can{$_parser} || '') =~ /sxc/i)
933 0 0 unless my $parser = $can{lc $parse_type}
937 0 0 $io_ref ? :
0 0 if $debug
938 0 0 if $opt{'passwd'}
940 0 0 $io_ref ? :
944 0 0 unless ($oBook)
949 0 0 if $debug > 8
966 0 0 if $debug
971 0 0 if $opt{'clip'} and $oWkS->row_max < $oWkS->row_min and $oWkS->col_max < $oWkS->col_min
984 0 0 unless defined $sheet{'label'}
990 0 0 unless $oWkS->get_merged_areas
992 0 0 if $debug
993 0 0 if (defined $active_sheet)
995 0 0 if $sheet_no eq $active_sheet
999 0 0 if ($opt{'clip'})
1003 0 0 unless my $oWkC = $oWkS->get_cell($r, $c)
1004 0 0 unless defined(my $val = $oWkC->value)
1005 0 0 if $val eq ''
1006 0 0 if $r > $mr
1007 0 0 if $c > $mc
1014 0 0 unless my $oWkC = $oWkS->get_cell($r, $c)
1020 0 0 if $opt{'rc'}
1025 0 0 if ($styleName and defined(my $s = $oBook->_styles->{$styleName}))
1029 0 0 if defined $fmt
1031 0 0 defined $val ? :
0 0 if $opt{'cells'}
1032 0 0 if ($opt{'attr'})
1033 0 0 $FmT ? :
1040 0 0 if $type eq 'float'
1069 0 0 if ($opt{'merge'} and $merged and my $p_cell = Spreadsheet::Read::Sheet::merged_from(\%sheet, $c + 1, $r + 1))
1072 0 0 if ($cell ne $p_cell)
1083 0 0 unless defined $_
1086 0 0 if ($sheet{'label'} eq '-- unlabeled --') { }
1096 49 25 $io_fil ? :
2 74 $opt{'parser'} ? :
46 30 if ($opt{'parser'} ? _parser($opt{'parser'}) eq 'sc' : ($io_fil ? $txt =~ /\.sc$/ : $txt =~ /^# .*SquirrelCalc/))
1100 2 44 if ($io_ref) { }
42 2 elsif ($io_fil) { }
1107 0 42 unless open my $sc, '<', $txt
1111 0 46 unless $txt =~ /\S/
1112 0 46 defined $opt{'label'} ? :
1138 46 13432 if (/^dimension.*of ([0-9]+) rows.*of ([0-9]+) columns/i)
1142 9890 3542 unless s/^r([0-9]+)c([0-9]+)\s*=\s*//
1144 2714 828 if (/.* \{(.*)}$/ or /"(.*)"/)
1146 2360 354 if $opt{'rc'}
1147 2714 0 if $opt{'cells'}
1148 236 2478 if $opt{'attr'}
1155 40 320 unless defined $_
1160 0 30 $opt{'parser'} ? :
7 23 if ($opt{'parser'} ? _parser($opt{'parser'}) eq 'sxc' : $txt =~ /^<\?xml/ || -f $txt)
1162 7 0 unless $can{'sxc'}
1164 0 0 if ref $txt and $can{'sxc'}->VERSION <= 0.23
1170 0 0 if ($txt =~ /\.(sxc|ods)$/i) { }
0 0 elsif (ref $txt) { }
0 0 elsif ($txt =~ /\.xml$/i) { }
0 0 elsif (not $txt =~ /^<\?xml/i and -f $txt) { }
1171 0 0 if $debug
1172 0 0 if $debug
1173 0 0 unless $sxc = Spreadsheet::ReadSXC::read_sxc($txt, $sxc_options)
1177 0 0 if $debug
1178 0 0 unless $sxc = Spreadsheet::ReadSXC::read_sxc_fh($txt, $sxc_options)
1181 0 0 if $debug
1182 0 0 unless $sxc = Spreadsheet::ReadSXC::read_xml_file($txt, $sxc_options)
1187 0 0 if $debug
1188 0 0 unless open my $f, '<', $txt
1193 0 0 if not $sxc and $txt =~ /^<\?xml/i
1195 0 0 if $debug > 8
1196 0 0 if ($sxc)
1216 0 0 ref $sxc eq 'HASH' ? :
1218 0 0 unless $sheet->{'data'}
1230 0 0 if $debug
1232 0 0 unless my(@row) = @{$sheet[$r];}
1234 0 0 unless defined(my $val = $row[$c])
1236 0 0 if $C > $sheet{'maxcol'}
1238 0 0 if $opt{'rc'}
1239 0 0 if $opt{'cells'}
1240 0 0 if $opt{'attr'}
1244 0 0 unless defined $_
1246 0 0 if $debug
1255 5 18 if (not ref $txt and $txt =~ /\.\w+$/)
1257 0 5 if open my $fh, '<', $txt
1268 0 2 unless my $r = ReadData(@_)
1270 0 2 unless $book and ref $book eq 'ARRAY' || ref $book eq 'Spreadsheet::Read' and $book->[0]{'sheets'}
1275 0 2 unless ($c1->{'parsers'})
1282 2 0 if $p->{'type'} eq $c2->{'type'} and $p->{'parser'} eq $c2->{'parser'}
1283 0 2 unless (defined $pidx)
1319 28 0 if @id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/
1321 27 0 if @id and $id[0] and exists $$sheet{$id[0]}
1328 12 0 if @id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/
1329 14 0 if (@id and $id[0] and exists $$sheet{$id[0]})
1347 1 0 if $_[0] =~ /::/
1352 24 10 if $_[0] =~ /::/
1357 30 3 if $_[0] =~ /::/
1363 1 1 if defined $label
1375 3 1 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1383 3 1 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1390 3 1 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}
1398 3 1 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}
1416 0 17 unless my $ma = $sheet->{'merged'}
1417 10 7 if (@id == 2 and $id[0] =~ /^[0-9]+$/ and $id[1] =~ /^[0-9]+$/) { }
3 4 elsif (@id and $id[0] and exists $$sheet{$id[0]}) { }
1423 1 12 unless defined $row and $row > 0 and $row <= $sheet->{'maxrow'}
1424 0 12 unless defined $col and $col > 0 and $col <= $sheet->{'maxcol'}
1427 10 12 unless $col >= $ctl and $col <= $cbr
1428 2 10 unless $row >= $rtl and $row <= $rbr