line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
############################################################################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Core - A class for writing the Excel XLSX core.xml file. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Used in conjunction with Excel::Writer::XLSX |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright 2000-2021, John McNamara, jmcnamara@cpan.org |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Documentation after __END__ |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# perltidy with the following options: -mbl=2 -pt=0 -nola |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use 5.008002; |
16
|
1124
|
|
|
1124
|
|
16433
|
use strict; |
|
1124
|
|
|
|
|
3305
|
|
17
|
1124
|
|
|
1124
|
|
5013
|
use warnings; |
|
1124
|
|
|
|
|
1887
|
|
|
1124
|
|
|
|
|
18068
|
|
18
|
1124
|
|
|
1124
|
|
4410
|
use Carp; |
|
1124
|
|
|
|
|
1959
|
|
|
1124
|
|
|
|
|
21334
|
|
19
|
1124
|
|
|
1124
|
|
4582
|
use Excel::Writer::XLSX::Package::XMLwriter; |
|
1124
|
|
|
|
|
2008
|
|
|
1124
|
|
|
|
|
48724
|
|
20
|
1124
|
|
|
1124
|
|
6180
|
|
|
1124
|
|
|
|
|
2222
|
|
|
1124
|
|
|
|
|
798202
|
|
21
|
|
|
|
|
|
|
our @ISA = qw(Excel::Writer::XLSX::Package::XMLwriter); |
22
|
|
|
|
|
|
|
our $VERSION = '1.09'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
############################################################################### |
26
|
|
|
|
|
|
|
# |
27
|
|
|
|
|
|
|
# Public and private API methods. |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
############################################################################### |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
############################################################################### |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# new() |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
# Constructor. |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $class = shift; |
40
|
|
|
|
|
|
|
my $fh = shift; |
41
|
895
|
|
|
895
|
0
|
3924
|
my $self = Excel::Writer::XLSX::Package::XMLwriter->new( $fh ); |
42
|
895
|
|
|
|
|
1929
|
|
43
|
895
|
|
|
|
|
3295
|
$self->{_properties} = {}; |
44
|
|
|
|
|
|
|
$self->{_createtime} = [ gmtime() ]; |
45
|
895
|
|
|
|
|
2613
|
|
46
|
895
|
|
|
|
|
5702
|
bless $self, $class; |
47
|
|
|
|
|
|
|
|
48
|
895
|
|
|
|
|
2385
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
895
|
|
|
|
|
3014
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
############################################################################### |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# _assemble_xml_file() |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# Assemble and write the XML file. |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->xml_declaration; |
62
|
894
|
|
|
894
|
|
3106
|
$self->_write_cp_core_properties(); |
63
|
|
|
|
|
|
|
$self->_write_dc_title(); |
64
|
894
|
|
|
|
|
6855
|
$self->_write_dc_subject(); |
65
|
894
|
|
|
|
|
5117
|
$self->_write_dc_creator(); |
66
|
894
|
|
|
|
|
4792
|
$self->_write_cp_keywords(); |
67
|
894
|
|
|
|
|
3681
|
$self->_write_dc_description(); |
68
|
894
|
|
|
|
|
3691
|
$self->_write_cp_last_modified_by(); |
69
|
894
|
|
|
|
|
3794
|
$self->_write_dcterms_created(); |
70
|
894
|
|
|
|
|
3793
|
$self->_write_dcterms_modified(); |
71
|
894
|
|
|
|
|
3527
|
$self->_write_cp_category(); |
72
|
894
|
|
|
|
|
3710
|
$self->_write_cp_content_status(); |
73
|
894
|
|
|
|
|
3635
|
|
74
|
894
|
|
|
|
|
3617
|
$self->xml_end_tag( 'cp:coreProperties' ); |
75
|
894
|
|
|
|
|
3515
|
|
76
|
|
|
|
|
|
|
# Close the XML writer filehandle. |
77
|
894
|
|
|
|
|
5408
|
$self->xml_get_fh()->close(); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
894
|
|
|
|
|
5594
|
|
81
|
|
|
|
|
|
|
############################################################################### |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# _set_properties() |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# Set the document properties. |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $self = shift; |
89
|
|
|
|
|
|
|
my $properties = shift; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$self->{_properties} = $properties; |
92
|
894
|
|
|
894
|
|
2139
|
} |
93
|
894
|
|
|
|
|
2814
|
|
94
|
|
|
|
|
|
|
|
95
|
894
|
|
|
|
|
6108
|
############################################################################### |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
# Internal methods. |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
############################################################################### |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
############################################################################### |
103
|
|
|
|
|
|
|
# |
104
|
|
|
|
|
|
|
# _datetime_to_iso8601_date() |
105
|
|
|
|
|
|
|
# |
106
|
|
|
|
|
|
|
# Convert a gmtime/localtime() date to a ISO 8601 style "2010-01-01T00:00:00Z" |
107
|
|
|
|
|
|
|
# date. Excel always treats this as a utc date/time. |
108
|
|
|
|
|
|
|
# |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $self = shift; |
111
|
|
|
|
|
|
|
my $gmtime = shift || $self->{_createtime}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my ( $seconds, $minutes, $hours, $day, $month, $year ) = @$gmtime; |
114
|
|
|
|
|
|
|
|
115
|
1788
|
|
|
1788
|
|
3328
|
$month++; |
116
|
1788
|
|
66
|
|
|
7238
|
$year += 1900; |
117
|
|
|
|
|
|
|
|
118
|
1788
|
|
|
|
|
4851
|
my $date = sprintf "%4d-%02d-%02dT%02d:%02d:%02dZ", $year, $month, $day, |
119
|
|
|
|
|
|
|
$hours, $minutes, $seconds; |
120
|
1788
|
|
|
|
|
2889
|
} |
121
|
1788
|
|
|
|
|
4112
|
|
122
|
|
|
|
|
|
|
|
123
|
1788
|
|
|
|
|
10274
|
############################################################################### |
124
|
|
|
|
|
|
|
# |
125
|
|
|
|
|
|
|
# XML writing methods. |
126
|
|
|
|
|
|
|
# |
127
|
|
|
|
|
|
|
############################################################################### |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
############################################################################### |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
# _write_cp_core_properties() |
133
|
|
|
|
|
|
|
# |
134
|
|
|
|
|
|
|
# Write the <cp:coreProperties> element. |
135
|
|
|
|
|
|
|
# |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $self = shift; |
138
|
|
|
|
|
|
|
my $xmlns_cp = |
139
|
|
|
|
|
|
|
'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'; |
140
|
|
|
|
|
|
|
my $xmlns_dc = 'http://purl.org/dc/elements/1.1/'; |
141
|
|
|
|
|
|
|
my $xmlns_dcterms = 'http://purl.org/dc/terms/'; |
142
|
|
|
|
|
|
|
my $xmlns_dcmitype = 'http://purl.org/dc/dcmitype/'; |
143
|
894
|
|
|
894
|
|
3360
|
my $xmlns_xsi = 'http://www.w3.org/2001/XMLSchema-instance'; |
144
|
894
|
|
|
|
|
2948
|
|
145
|
|
|
|
|
|
|
my @attributes = ( |
146
|
894
|
|
|
|
|
2066
|
'xmlns:cp' => $xmlns_cp, |
147
|
894
|
|
|
|
|
2236
|
'xmlns:dc' => $xmlns_dc, |
148
|
894
|
|
|
|
|
2647
|
'xmlns:dcterms' => $xmlns_dcterms, |
149
|
894
|
|
|
|
|
2239
|
'xmlns:dcmitype' => $xmlns_dcmitype, |
150
|
|
|
|
|
|
|
'xmlns:xsi' => $xmlns_xsi, |
151
|
894
|
|
|
|
|
4169
|
); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$self->xml_start_tag( 'cp:coreProperties', @attributes ); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
############################################################################### |
158
|
|
|
|
|
|
|
# |
159
|
894
|
|
|
|
|
5648
|
# _write_dc_creator() |
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
# Write the <dc:creator> element. |
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $self = shift; |
165
|
|
|
|
|
|
|
my $data = $self->{_properties}->{author} || ''; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$self->xml_data_element( 'dc:creator', $data ); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
894
|
|
|
894
|
|
2512
|
############################################################################### |
172
|
894
|
|
100
|
|
|
6029
|
# |
173
|
|
|
|
|
|
|
# _write_cp_last_modified_by() |
174
|
894
|
|
|
|
|
4873
|
# |
175
|
|
|
|
|
|
|
# Write the <cp:lastModifiedBy> element. |
176
|
|
|
|
|
|
|
# |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $self = shift; |
179
|
|
|
|
|
|
|
my $data = $self->{_properties}->{author} || ''; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$self->xml_data_element( 'cp:lastModifiedBy', $data ); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
############################################################################### |
186
|
894
|
|
|
894
|
|
3038
|
# |
187
|
894
|
|
100
|
|
|
5630
|
# _write_dcterms_created() |
188
|
|
|
|
|
|
|
# |
189
|
894
|
|
|
|
|
3914
|
# Write the <dcterms:created> element. |
190
|
|
|
|
|
|
|
# |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $self = shift; |
193
|
|
|
|
|
|
|
my $date = $self->{_properties}->{created}; |
194
|
|
|
|
|
|
|
my $xsi_type = 'dcterms:W3CDTF'; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
$date = $self->_datetime_to_iso8601_date( $date ); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
my @attributes = ( 'xsi:type' => $xsi_type, ); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$self->xml_data_element( 'dcterms:created', $date, @attributes ); |
201
|
894
|
|
|
894
|
|
2668
|
} |
202
|
894
|
|
|
|
|
2463
|
|
203
|
894
|
|
|
|
|
1878
|
|
204
|
|
|
|
|
|
|
############################################################################### |
205
|
894
|
|
|
|
|
3529
|
# |
206
|
|
|
|
|
|
|
# _write_dcterms_modified() |
207
|
894
|
|
|
|
|
2945
|
# |
208
|
|
|
|
|
|
|
# Write the <dcterms:modified> element. |
209
|
894
|
|
|
|
|
4075
|
# |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
my $self = shift; |
212
|
|
|
|
|
|
|
my $date = $self->{_properties}->{created}; |
213
|
|
|
|
|
|
|
my $xsi_type = 'dcterms:W3CDTF'; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$date = $self->_datetime_to_iso8601_date( $date ); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my @attributes = ( 'xsi:type' => $xsi_type, ); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
$self->xml_data_element( 'dcterms:modified', $date, @attributes ); |
220
|
|
|
|
|
|
|
} |
221
|
894
|
|
|
894
|
|
3316
|
|
222
|
894
|
|
|
|
|
2835
|
|
223
|
894
|
|
|
|
|
2233
|
############################################################################## |
224
|
|
|
|
|
|
|
# |
225
|
894
|
|
|
|
|
2761
|
# _write_dc_title() |
226
|
|
|
|
|
|
|
# |
227
|
894
|
|
|
|
|
3444
|
# Write the <dc:title> element. |
228
|
|
|
|
|
|
|
# |
229
|
894
|
|
|
|
|
3567
|
|
230
|
|
|
|
|
|
|
my $self = shift; |
231
|
|
|
|
|
|
|
my $data = $self->{_properties}->{title}; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
return unless $data; |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
$self->xml_data_element( 'dc:title', $data ); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
############################################################################## |
240
|
|
|
|
|
|
|
# |
241
|
894
|
|
|
894
|
|
2013
|
# _write_dc_subject() |
242
|
894
|
|
|
|
|
2687
|
# |
243
|
|
|
|
|
|
|
# Write the <dc:subject> element. |
244
|
894
|
100
|
|
|
|
3516
|
# |
245
|
|
|
|
|
|
|
|
246
|
2
|
|
|
|
|
11
|
my $self = shift; |
247
|
|
|
|
|
|
|
my $data = $self->{_properties}->{subject}; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
return unless $data; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$self->xml_data_element( 'dc:subject', $data ); |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
############################################################################## |
256
|
|
|
|
|
|
|
# |
257
|
|
|
|
|
|
|
# _write_cp_keywords() |
258
|
894
|
|
|
894
|
|
2343
|
# |
259
|
894
|
|
|
|
|
2421
|
# Write the <cp:keywords> element. |
260
|
|
|
|
|
|
|
# |
261
|
894
|
100
|
|
|
|
3140
|
|
262
|
|
|
|
|
|
|
my $self = shift; |
263
|
2
|
|
|
|
|
6
|
my $data = $self->{_properties}->{keywords}; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
return unless $data; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
$self->xml_data_element( 'cp:keywords', $data ); |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
############################################################################## |
272
|
|
|
|
|
|
|
# |
273
|
|
|
|
|
|
|
# _write_dc_description() |
274
|
|
|
|
|
|
|
# |
275
|
894
|
|
|
894
|
|
2427
|
# Write the <dc:description> element. |
276
|
894
|
|
|
|
|
2361
|
# |
277
|
|
|
|
|
|
|
|
278
|
894
|
100
|
|
|
|
3539
|
my $self = shift; |
279
|
|
|
|
|
|
|
my $data = $self->{_properties}->{comments}; |
280
|
2
|
|
|
|
|
5
|
|
281
|
|
|
|
|
|
|
return unless $data; |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
$self->xml_data_element( 'dc:description', $data ); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
############################################################################## |
288
|
|
|
|
|
|
|
# |
289
|
|
|
|
|
|
|
# _write_cp_category() |
290
|
|
|
|
|
|
|
# |
291
|
|
|
|
|
|
|
# Write the <cp:category> element. |
292
|
894
|
|
|
894
|
|
2586
|
# |
293
|
894
|
|
|
|
|
2268
|
|
294
|
|
|
|
|
|
|
my $self = shift; |
295
|
894
|
100
|
|
|
|
3280
|
my $data = $self->{_properties}->{category}; |
296
|
|
|
|
|
|
|
|
297
|
2
|
|
|
|
|
5
|
return unless $data; |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
$self->xml_data_element( 'cp:category', $data ); |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
############################################################################## |
304
|
|
|
|
|
|
|
# |
305
|
|
|
|
|
|
|
# _write_cp_content_status() |
306
|
|
|
|
|
|
|
# |
307
|
|
|
|
|
|
|
# Write the <cp:contentStatus> element. |
308
|
|
|
|
|
|
|
# |
309
|
894
|
|
|
894
|
|
2093
|
|
310
|
894
|
|
|
|
|
2460
|
my $self = shift; |
311
|
|
|
|
|
|
|
my $data = $self->{_properties}->{status}; |
312
|
894
|
100
|
|
|
|
3236
|
|
313
|
|
|
|
|
|
|
return unless $data; |
314
|
2
|
|
|
|
|
4
|
|
315
|
|
|
|
|
|
|
$self->xml_data_element( 'cp:contentStatus', $data ); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
1; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=pod |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head1 NAME |
326
|
894
|
|
|
894
|
|
2461
|
|
327
|
894
|
|
|
|
|
2367
|
Core - A class for writing the Excel XLSX core.xml file. |
328
|
|
|
|
|
|
|
|
329
|
894
|
100
|
|
|
|
3227
|
=head1 SYNOPSIS |
330
|
|
|
|
|
|
|
|
331
|
2
|
|
|
|
|
6
|
See the documentation for L<Excel::Writer::XLSX>. |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=head1 DESCRIPTION |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
This module is used in conjunction with L<Excel::Writer::XLSX>. |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=head1 AUTHOR |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
John McNamara jmcnamara@cpan.org |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head1 COPYRIGHT |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
(c) MM-MMXXI, John McNamara. |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=head1 LICENSE |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
Either the Perl Artistic Licence L<http://dev.perl.org/licenses/artistic.html> or the GPL L<http://www.opensource.org/licenses/gpl-license.php>. |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
See the documentation for L<Excel::Writer::XLSX>. |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=cut |