line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookRels; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JANDREW'; |
3
|
3
|
|
|
3
|
|
10549
|
use version; our $VERSION = version->declare('v0.16.8'); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
25
|
|
4
|
|
|
|
|
|
|
###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookRels-$VERSION"; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
295
|
use Moose::Role; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
requires qw( get_sheet_info get_sheet_names good_load ); |
8
|
|
|
|
|
|
|
###LogSD requires 'get_log_space', 'get_all_space'; |
9
|
3
|
|
|
3
|
|
11194
|
use Types::Standard qw( Enum ArrayRef HashRef Bool ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
27
|
|
10
|
3
|
|
|
3
|
|
2206
|
use Data::Dumper; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
172
|
|
11
|
3
|
|
|
3
|
|
12
|
use lib '../../../../../lib',; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
20
|
|
12
|
|
|
|
|
|
|
###LogSD use Log::Shiras::Telephone; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#########1 Public Attributes 3#########4#########5#########6#########7#########8#########9 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#########1 Public Methods 3#########4#########5#########6#########7#########8#########9 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub load_unique_bits{ |
25
|
4
|
|
|
4
|
1
|
8
|
my( $self, ) = @_; |
26
|
|
|
|
|
|
|
###LogSD my $phone = Log::Shiras::Telephone->new( name_space => |
27
|
|
|
|
|
|
|
###LogSD $self->get_all_space . '::load_unique_bits', ); |
28
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
29
|
|
|
|
|
|
|
###LogSD "Setting the WorkbookRelsInterface unique bits" ] ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Build the list |
32
|
4
|
|
|
|
|
5
|
my ( $worksheet_list, $chartsheet_list ); |
33
|
4
|
|
|
|
|
31
|
my $sheet_name_list = $self->get_sheet_names; |
34
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
35
|
|
|
|
|
|
|
###LogSD "Adding the sheet name list:", $sheet_name_list ] ); |
36
|
4
|
50
|
|
|
|
32
|
map{ $self->_add_worksheet( $_ ) if $_ } @$sheet_name_list if $sheet_name_list; |
|
10
|
50
|
|
|
|
333
|
|
37
|
|
|
|
|
|
|
# No chartsheets in xml flat files |
38
|
4
|
|
|
|
|
11
|
for my $sheet ( @$sheet_name_list ){ |
39
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
40
|
|
|
|
|
|
|
###LogSD "Categorizing sheet: $sheet" ] ); |
41
|
10
|
|
|
|
|
46
|
my $sheet_ref = $self->get_sheet_info( $sheet ); |
42
|
|
|
|
|
|
|
$sheet_ref->{sheet_type} = 'worksheet', |
43
|
10
|
|
|
|
|
94
|
$sheet_ref->{file} = [[ 'Worksheet', $sheet ]]; |
44
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
45
|
|
|
|
|
|
|
###LogSD "Updated sheet ref:", $sheet_ref ] ); |
46
|
10
|
|
|
|
|
337
|
$self->_set_sheet_info( $sheet => $sheet_ref );# No update needed for XML flat files - pass through |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'trace', message => [ |
50
|
|
|
|
|
|
|
###LogSD "Closing out the xml file" ] ); |
51
|
4
|
|
|
|
|
24
|
$self->close_the_file; |
52
|
4
|
|
|
|
|
118
|
$self->good_load( 1 ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#########1 Private Attributes 3#########4#########5#########6#########7#########8#########9 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has _sheet_lookup =>( |
58
|
|
|
|
|
|
|
isa => HashRef, |
59
|
|
|
|
|
|
|
traits => ['Hash'], |
60
|
|
|
|
|
|
|
reader => 'get_sheet_lookup', |
61
|
|
|
|
|
|
|
handles =>{ |
62
|
|
|
|
|
|
|
_set_sheet_info => 'set', |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
default => sub{ {} }, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has _worksheet_list =>( |
68
|
|
|
|
|
|
|
isa => ArrayRef, |
69
|
|
|
|
|
|
|
traits => ['Array'], |
70
|
|
|
|
|
|
|
reader => 'get_worksheet_list', |
71
|
|
|
|
|
|
|
handles =>{ |
72
|
|
|
|
|
|
|
_add_worksheet => 'push', |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
default => sub{ [] }, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has _chartsheet_list =>( |
78
|
|
|
|
|
|
|
isa => ArrayRef, |
79
|
|
|
|
|
|
|
traits => ['Array'], |
80
|
|
|
|
|
|
|
reader => 'get_chartsheet_list', |
81
|
|
|
|
|
|
|
handles =>{ |
82
|
|
|
|
|
|
|
_add_chartsheet => 'push', |
83
|
|
|
|
|
|
|
}, |
84
|
|
|
|
|
|
|
default => sub{ [] }, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#########1 Private Methods 3#########4#########5#########6#########7#########8#########9 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#########1 Phinish 3#########4#########5#########6#########7#########8#########9 |
92
|
|
|
|
|
|
|
|
93
|
3
|
|
|
3
|
|
935
|
no Moose::Role; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
12
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#########1 Documentation 3#########4#########5#########6#########7#########8#########9 |
97
|
|
|
|
|
|
|
__END__ |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookRels - Workbook Rels XML file unique reader |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
use Types::Standard qw( HashRef ); |
106
|
|
|
|
|
|
|
use MooseX::ShortCut::BuildInstance qw( build_instance ); |
107
|
|
|
|
|
|
|
my $workbook_instance = build_instance( |
108
|
|
|
|
|
|
|
package => 'Spreadsheet::Reader::ExcelXML::Workbook', |
109
|
|
|
|
|
|
|
add_attributes =>{ |
110
|
|
|
|
|
|
|
_rel_lookup =>{ |
111
|
|
|
|
|
|
|
isa => HashRef, |
112
|
|
|
|
|
|
|
traits => ['Hash'], |
113
|
|
|
|
|
|
|
handles =>{ get_rel_info => 'get', }, |
114
|
|
|
|
|
|
|
default => sub{ { |
115
|
|
|
|
|
|
|
'rId2' => 'Sheet5', |
116
|
|
|
|
|
|
|
'rId3' => 'Sheet1', |
117
|
|
|
|
|
|
|
'rId1' => 'Sheet2' |
118
|
|
|
|
|
|
|
} }, |
119
|
|
|
|
|
|
|
}, |
120
|
|
|
|
|
|
|
_sheet_lookup =>{ |
121
|
|
|
|
|
|
|
isa => HashRef, |
122
|
|
|
|
|
|
|
traits => ['Hash'], |
123
|
|
|
|
|
|
|
handles =>{ get_sheet_info => 'get', }, |
124
|
|
|
|
|
|
|
default => sub{ { |
125
|
|
|
|
|
|
|
'Sheet1' => { |
126
|
|
|
|
|
|
|
'sheet_id' => '1', |
127
|
|
|
|
|
|
|
'sheet_position' => 2, |
128
|
|
|
|
|
|
|
'sheet_name' => 'Sheet1', |
129
|
|
|
|
|
|
|
'is_hidden' => 0, |
130
|
|
|
|
|
|
|
'sheet_rel_id' => 'rId3' |
131
|
|
|
|
|
|
|
}, |
132
|
|
|
|
|
|
|
'Sheet2' => { |
133
|
|
|
|
|
|
|
'sheet_position' => 0, |
134
|
|
|
|
|
|
|
'sheet_name' => 'Sheet2', |
135
|
|
|
|
|
|
|
'sheet_id' => '2', |
136
|
|
|
|
|
|
|
'sheet_rel_id' => 'rId1', |
137
|
|
|
|
|
|
|
'is_hidden' => 0 |
138
|
|
|
|
|
|
|
}, |
139
|
|
|
|
|
|
|
'Sheet5' => { |
140
|
|
|
|
|
|
|
'sheet_position' => 1, |
141
|
|
|
|
|
|
|
'sheet_name' => 'Sheet5', |
142
|
|
|
|
|
|
|
'sheet_id' => '3', |
143
|
|
|
|
|
|
|
'sheet_rel_id' => 'rId2', |
144
|
|
|
|
|
|
|
'is_hidden' => 1 |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} }, |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
}, |
149
|
|
|
|
|
|
|
add_methods =>{ |
150
|
|
|
|
|
|
|
get_sheet_names => sub{ [ |
151
|
|
|
|
|
|
|
'Sheet2', |
152
|
|
|
|
|
|
|
'Sheet5', |
153
|
|
|
|
|
|
|
'Sheet1' |
154
|
|
|
|
|
|
|
] }, |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
my $file_handle = File::Temp->new(); |
158
|
|
|
|
|
|
|
print $file_handle '<?xml version="1.0"?><NO_FILE/>';# The rels meta data is inferred, not parsed |
159
|
|
|
|
|
|
|
my $rels_instance = build_instance( |
160
|
|
|
|
|
|
|
superclasses => ['Spreadsheet::Reader::ExcelXML::XMLReader'], |
161
|
|
|
|
|
|
|
package => 'WorkbookRelsInterface', |
162
|
|
|
|
|
|
|
add_roles_in_sequence =>[ |
163
|
|
|
|
|
|
|
'Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookRels', |
164
|
|
|
|
|
|
|
'Spreadsheet::Reader::ExcelXML::WorkbookRelsInterface', |
165
|
|
|
|
|
|
|
], |
166
|
|
|
|
|
|
|
file => $file_handle, |
167
|
|
|
|
|
|
|
workbook_inst => $workbook_instance, |
168
|
|
|
|
|
|
|
); |
169
|
|
|
|
|
|
|
print Dumper( $rels_instance->get_worksheet_list ); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
########################### |
172
|
|
|
|
|
|
|
# SYNOPSIS Screen Output |
173
|
|
|
|
|
|
|
# 01: $VAR1 = [ |
174
|
|
|
|
|
|
|
# 02: 'Sheet2', |
175
|
|
|
|
|
|
|
# 03: 'Sheet5', |
176
|
|
|
|
|
|
|
# 04: 'Sheet1' |
177
|
|
|
|
|
|
|
# 05: ] |
178
|
|
|
|
|
|
|
########################### |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 DESCRIPTION |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This documentation is written to explain ways to use this module when writing your own |
183
|
|
|
|
|
|
|
excel parser. To use the general package for excel parsing out of the box please review |
184
|
|
|
|
|
|
|
the documentation for L<Workbooks|Spreadsheet::Reader::ExcelXML>, |
185
|
|
|
|
|
|
|
L<Worksheets|Spreadsheet::Reader::ExcelXML::Worksheet>, and |
186
|
|
|
|
|
|
|
L<Cells|Spreadsheet::Reader::ExcelXML::Cell> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This is the XML based file adaptor for reading the workbook rels data and then updating |
189
|
|
|
|
|
|
|
the general workbook metadata. All the rels data for flat xml files is inferred so the |
190
|
|
|
|
|
|
|
primary function is to transform the previously stored meta data for the rels stage. |
191
|
|
|
|
|
|
|
The transformed data is then accesable through L<Methods|/Methods>. The goal is to |
192
|
|
|
|
|
|
|
standardize the outputs of this transformation metadata from non standard inputs. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 Required Methods |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
These are the methods required by the role. A link to the default implementation of |
197
|
|
|
|
|
|
|
these methods is provided. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML/get_sheet_info( $name )> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML/get_sheet_names> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML::XMLReader/good_load( $state )> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 Methods |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
These are the methods provided by this role (only). |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head3 load_unique_bits |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
B<Definition:> This role is meant to run on top of L<Spreadsheet::Reader::ExcelXML::XMLReader>. |
214
|
|
|
|
|
|
|
When it does the reader will call this function as available when it first starts the file. |
215
|
|
|
|
|
|
|
Therefore this is where the unique Metadata for this file is found and stored. (in the |
216
|
|
|
|
|
|
|
attributes) |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
B<Accepts:> nothing |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
B<Returns:> nothing |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=back |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head3 get_sheet_lookup |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
B<Definition:> The sheet lookup is a hashref with keys as sheet names and the values are a sub |
229
|
|
|
|
|
|
|
hashref with $key => $value pairs of sheet meta data containing information like hiddeness and |
230
|
|
|
|
|
|
|
location. This method returns the full set. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
B<Accepts:> nothing |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
B<Returns:> a full hashref of hashrefs |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=back |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head3 get_worksheet_list |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=over |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
B<Definition:> returns an ordered arrayref conataining only worksheet names in their visible order |
243
|
|
|
|
|
|
|
from the Excel workbook. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
B<Accepts:> nothing |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
B<Returns:> an arrayref of names |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=back |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head3 get_chartsheet_list |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=over |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
B<Definition:> returns an ordered arrayref conataining only chartsheet names in their visible order |
256
|
|
|
|
|
|
|
from the Excel workbook. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
B<Accepts:> nothing |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
B<Returns:> an arrayref of names |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 SUPPORT |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=over |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
L<github Spreadsheet::Reader::ExcelXML/issues |
269
|
|
|
|
|
|
|
|https://github.com/jandrew/p5-spreadsheet-reader-excelxml/issues> |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=back |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 TODO |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=over |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
B<1.> Nothing currently |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=back |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head1 AUTHOR |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=over |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=item Jed Lund |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item jandrew@cpan.org |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=back |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 COPYRIGHT |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
This program is free software; you can redistribute |
294
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
The full text of the license can be found in the |
297
|
|
|
|
|
|
|
LICENSE file included with this module. |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
This software is copyrighted (c) 2016 by Jed Lund |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=over |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML> - the package |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=back |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head1 SEE ALSO |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=over |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
L<Spreadsheet::Read> - generic Spreadsheet reader |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
L<Spreadsheet::ParseExcel> - Excel binary version 2003 and earlier (.xls files) |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
L<Spreadsheet::XLSX> - Excel version 2007 and later |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
L<Spreadsheet::ParseXLSX> - Excel version 2007 and later |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
L<Log::Shiras|https://github.com/jandrew/Log-Shiras> |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=over |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
All lines in this package that use Log::Shiras are commented out |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=back |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=back |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
#########1#########2 main pod documentation end 5#########6#########7#########8#########9 |