line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::XLSX::Parser; |
2
|
7
|
|
|
7
|
|
169700
|
use strict; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
215
|
|
3
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
319
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
4200
|
use Data::XLSX::Parser::DocumentArchive; |
|
7
|
|
|
|
|
26
|
|
|
7
|
|
|
|
|
272
|
|
8
|
7
|
|
|
7
|
|
4064
|
use Data::XLSX::Parser::Workbook; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Data::XLSX::Parser::SharedStrings; |
10
|
|
|
|
|
|
|
use Data::XLSX::Parser::Styles; |
11
|
|
|
|
|
|
|
use Data::XLSX::Parser::Sheet; |
12
|
|
|
|
|
|
|
use Data::XLSX::Parser::Relationships; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $workbook_schema = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
|
|
|
|
|
|
my ($class) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
bless { |
20
|
|
|
|
|
|
|
_row_event_handler => [], |
21
|
|
|
|
|
|
|
_archive => undef, |
22
|
|
|
|
|
|
|
_workbook => undef, |
23
|
|
|
|
|
|
|
_shared_strings => undef, |
24
|
|
|
|
|
|
|
_relationships => undef, |
25
|
|
|
|
|
|
|
}, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub add_row_event_handler { |
29
|
|
|
|
|
|
|
my ($self, $handler) = @_; |
30
|
|
|
|
|
|
|
push @{ $self->{_row_event_handler} }, $handler; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub open { |
34
|
|
|
|
|
|
|
my ($self, $file) = @_; |
35
|
|
|
|
|
|
|
$self->{_archive} = Data::XLSX::Parser::DocumentArchive->new($file); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub workbook { |
39
|
|
|
|
|
|
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
$self->{_workbook} ||= Data::XLSX::Parser::Workbook->new($self->{_archive}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub shared_strings { |
44
|
|
|
|
|
|
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
$self->{_shared_strings} ||= Data::XLSX::Parser::SharedStrings->new($self->{_archive}); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub styles { |
49
|
|
|
|
|
|
|
my ($self) = @_; |
50
|
|
|
|
|
|
|
$self->{_styles} ||= Data::XLSX::Parser::Styles->new($self->{_archive}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub relationships { |
54
|
|
|
|
|
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
$self->{_relationships} ||= Data::XLSX::Parser::Relationships->new($self->{_archive}); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub sheet { |
59
|
|
|
|
|
|
|
my ($self, $sheet_id) = @_; |
60
|
|
|
|
|
|
|
warn 'Data::XLSX::Parser->sheet is obsolete. This method will remove feature release.'; |
61
|
|
|
|
|
|
|
$self->{_sheet}->{$sheet_id} ||= Data::XLSX::Parser::Sheet->new($self, $self->{_archive}, $sheet_id); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub sheet_by_rid { |
65
|
|
|
|
|
|
|
my ($self, $rid) = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $relation = $self->relationships->relation($rid); |
68
|
|
|
|
|
|
|
unless ($relation) { |
69
|
|
|
|
|
|
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if ($relation->{Type} eq $workbook_schema) { |
73
|
|
|
|
|
|
|
my $target = $relation->{Target}; |
74
|
|
|
|
|
|
|
$self->{_sheet}->{$rid} ||= |
75
|
|
|
|
|
|
|
Data::XLSX::Parser::Sheet->new($self, $self->{_archive}, $target); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _row_event { |
80
|
|
|
|
|
|
|
my ($self, $row) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $row_vals = [map { $_->{v} } @$row]; |
83
|
|
|
|
|
|
|
for my $handler (@{ $self->{_row_event_handler} }) { |
84
|
|
|
|
|
|
|
$handler->($row_vals); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |