line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
############################################################################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Table - A class for writing the Excel XLSX Table 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
|
|
19085
|
use strict; |
|
1124
|
|
|
|
|
3236
|
|
17
|
1124
|
|
|
1124
|
|
5241
|
use warnings; |
|
1124
|
|
|
|
|
1892
|
|
|
1124
|
|
|
|
|
19453
|
|
18
|
1124
|
|
|
1124
|
|
4730
|
use Carp; |
|
1124
|
|
|
|
|
1844
|
|
|
1124
|
|
|
|
|
22640
|
|
19
|
1124
|
|
|
1124
|
|
4543
|
use Excel::Writer::XLSX::Package::XMLwriter; |
|
1124
|
|
|
|
|
2049
|
|
|
1124
|
|
|
|
|
50375
|
|
20
|
1124
|
|
|
1124
|
|
6092
|
|
|
1124
|
|
|
|
|
2233
|
|
|
1124
|
|
|
|
|
765372
|
|
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
|
52
|
|
|
52
|
0
|
9660
|
my $self = Excel::Writer::XLSX::Package::XMLwriter->new( $fh ); |
42
|
52
|
|
|
|
|
95
|
|
43
|
52
|
|
|
|
|
253
|
$self->{_properties} = {}; |
44
|
|
|
|
|
|
|
|
45
|
52
|
|
|
|
|
202
|
bless $self, $class; |
46
|
|
|
|
|
|
|
|
47
|
52
|
|
|
|
|
119
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
52
|
|
|
|
|
127
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
############################################################################### |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
# _assemble_xml_file() |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
# Assemble and write the XML file. |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->xml_declaration; |
61
|
49
|
|
|
49
|
|
119
|
|
62
|
|
|
|
|
|
|
# Write the table element. |
63
|
49
|
|
|
|
|
367
|
$self->_write_table(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Write the autoFilter element. |
66
|
49
|
|
|
|
|
313
|
$self->_write_auto_filter(); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Write the tableColumns element. |
69
|
49
|
|
|
|
|
188
|
$self->_write_table_columns(); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Write the tableStyleInfo element. |
72
|
49
|
|
|
|
|
167
|
$self->_write_table_style_info(); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
49
|
|
|
|
|
168
|
# Close the table tag. |
76
|
|
|
|
|
|
|
$self->xml_end_tag( 'table' ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Close the XML writer filehandle. |
79
|
49
|
|
|
|
|
162
|
$self->xml_get_fh()->close(); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
49
|
|
|
|
|
203
|
|
83
|
|
|
|
|
|
|
############################################################################### |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# _set_properties() |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
# Set the document properties. |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
my $properties = shift; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$self->{_properties} = $properties; |
94
|
49
|
|
|
49
|
|
155
|
} |
95
|
49
|
|
|
|
|
191
|
|
96
|
|
|
|
|
|
|
|
97
|
49
|
|
|
|
|
311
|
############################################################################### |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
# Internal methods. |
100
|
|
|
|
|
|
|
# |
101
|
|
|
|
|
|
|
############################################################################### |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
############################################################################### |
105
|
|
|
|
|
|
|
# |
106
|
|
|
|
|
|
|
# XML writing methods. |
107
|
|
|
|
|
|
|
# |
108
|
|
|
|
|
|
|
############################################################################### |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
############################################################################## |
112
|
|
|
|
|
|
|
# |
113
|
|
|
|
|
|
|
# _write_table() |
114
|
|
|
|
|
|
|
# |
115
|
|
|
|
|
|
|
# Write the <table> element. |
116
|
|
|
|
|
|
|
# |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $self = shift; |
119
|
|
|
|
|
|
|
my $schema = 'http://schemas.openxmlformats.org/'; |
120
|
|
|
|
|
|
|
my $xmlns = $schema . 'spreadsheetml/2006/main'; |
121
|
|
|
|
|
|
|
my $id = $self->{_properties}->{_id}; |
122
|
|
|
|
|
|
|
my $name = $self->{_properties}->{_name}; |
123
|
49
|
|
|
49
|
|
111
|
my $display_name = $self->{_properties}->{_name}; |
124
|
49
|
|
|
|
|
92
|
my $ref = $self->{_properties}->{_range}; |
125
|
49
|
|
|
|
|
152
|
my $totals_row_shown = $self->{_properties}->{_totals_row_shown}; |
126
|
49
|
|
|
|
|
121
|
my $header_row_count = $self->{_properties}->{_header_row_count}; |
127
|
49
|
|
|
|
|
107
|
|
128
|
49
|
|
|
|
|
102
|
my @attributes = ( |
129
|
49
|
|
|
|
|
106
|
'xmlns' => $xmlns, |
130
|
49
|
|
|
|
|
97
|
'id' => $id, |
131
|
49
|
|
|
|
|
155
|
'name' => $name, |
132
|
|
|
|
|
|
|
'displayName' => $display_name, |
133
|
49
|
|
|
|
|
204
|
'ref' => $ref, |
134
|
|
|
|
|
|
|
); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
push @attributes, ( 'headerRowCount' => 0 ) if !$header_row_count; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
if ( $totals_row_shown ) { |
139
|
|
|
|
|
|
|
push @attributes, ( 'totalsRowCount' => 1 ); |
140
|
|
|
|
|
|
|
} |
141
|
49
|
100
|
|
|
|
199
|
else { |
142
|
|
|
|
|
|
|
push @attributes, ( 'totalsRowShown' => 0 ); |
143
|
49
|
100
|
|
|
|
190
|
} |
144
|
10
|
|
|
|
|
28
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$self->xml_start_tag( 'table', @attributes ); |
147
|
39
|
|
|
|
|
113
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
############################################################################## |
151
|
49
|
|
|
|
|
291
|
# |
152
|
|
|
|
|
|
|
# _write_auto_filter() |
153
|
|
|
|
|
|
|
# |
154
|
|
|
|
|
|
|
# Write the <autoFilter> element. |
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
my $self = shift; |
158
|
|
|
|
|
|
|
my $autofilter = $self->{_properties}->{_autofilter}; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
return unless $autofilter; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my @attributes = ( 'ref' => $autofilter, ); |
163
|
50
|
|
|
50
|
|
99
|
|
164
|
50
|
|
|
|
|
112
|
$self->xml_empty_tag( 'autoFilter', @attributes ); |
165
|
|
|
|
|
|
|
} |
166
|
50
|
100
|
|
|
|
148
|
|
167
|
|
|
|
|
|
|
|
168
|
45
|
|
|
|
|
134
|
############################################################################## |
169
|
|
|
|
|
|
|
# |
170
|
45
|
|
|
|
|
211
|
# _write_table_columns() |
171
|
|
|
|
|
|
|
# |
172
|
|
|
|
|
|
|
# Write the <tableColumns> element. |
173
|
|
|
|
|
|
|
# |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $self = shift; |
176
|
|
|
|
|
|
|
my @columns = @{ $self->{_properties}->{_columns} }; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $count = scalar @columns; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my @attributes = ( 'count' => $count, ); |
181
|
|
|
|
|
|
|
|
182
|
49
|
|
|
49
|
|
91
|
$self->xml_start_tag( 'tableColumns', @attributes ); |
183
|
49
|
|
|
|
|
98
|
|
|
49
|
|
|
|
|
174
|
|
184
|
|
|
|
|
|
|
for my $col_data ( @columns ) { |
185
|
49
|
|
|
|
|
109
|
|
186
|
|
|
|
|
|
|
# Write the tableColumn element. |
187
|
49
|
|
|
|
|
107
|
$self->_write_table_column( $col_data ); |
188
|
|
|
|
|
|
|
} |
189
|
49
|
|
|
|
|
168
|
|
190
|
|
|
|
|
|
|
$self->xml_end_tag( 'tableColumns' ); |
191
|
49
|
|
|
|
|
295
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
214
|
|
|
|
|
420
|
############################################################################## |
195
|
|
|
|
|
|
|
# |
196
|
|
|
|
|
|
|
# _write_table_column() |
197
|
49
|
|
|
|
|
229
|
# |
198
|
|
|
|
|
|
|
# Write the <tableColumn> element. |
199
|
|
|
|
|
|
|
# |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my $self = shift; |
202
|
|
|
|
|
|
|
my $col_data = shift; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my @attributes = ( |
205
|
|
|
|
|
|
|
'id' => $col_data->{_id}, |
206
|
|
|
|
|
|
|
'name' => $col_data->{_name}, |
207
|
|
|
|
|
|
|
); |
208
|
|
|
|
|
|
|
|
209
|
215
|
|
|
215
|
|
314
|
|
210
|
215
|
|
|
|
|
401
|
if ( $col_data->{_total_string} ) { |
211
|
|
|
|
|
|
|
push @attributes, ( totalsRowLabel => $col_data->{_total_string} ); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
elsif ( $col_data->{_total_function} ) { |
214
|
|
|
|
|
|
|
push @attributes, ( totalsRowFunction => $col_data->{_total_function} ); |
215
|
215
|
|
|
|
|
853
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
215
|
100
|
|
|
|
539
|
if ( defined $col_data->{_format} ) { |
|
|
100
|
|
|
|
|
|
219
|
9
|
|
|
|
|
93
|
push @attributes, ( dataDxfId => $col_data->{_format} ); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
40
|
|
|
|
|
70
|
if ( $col_data->{_formula} ) { |
223
|
|
|
|
|
|
|
$self->xml_start_tag( 'tableColumn', @attributes ); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# Write the calculatedColumnFormula element. |
226
|
215
|
100
|
|
|
|
699
|
$self->_write_calculated_column_formula( $col_data->{_formula} ); |
227
|
9
|
|
|
|
|
18
|
|
228
|
|
|
|
|
|
|
$self->xml_end_tag( 'tableColumn' ); |
229
|
|
|
|
|
|
|
} |
230
|
215
|
100
|
|
|
|
483
|
else { |
231
|
3
|
|
|
|
|
11
|
$self->xml_empty_tag( 'tableColumn', @attributes ); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
3
|
|
|
|
|
13
|
} |
235
|
|
|
|
|
|
|
|
236
|
3
|
|
|
|
|
13
|
|
237
|
|
|
|
|
|
|
############################################################################## |
238
|
|
|
|
|
|
|
# |
239
|
212
|
|
|
|
|
552
|
# _write_table_style_info() |
240
|
|
|
|
|
|
|
# |
241
|
|
|
|
|
|
|
# Write the <tableStyleInfo> element. |
242
|
|
|
|
|
|
|
# |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
my $self = shift; |
245
|
|
|
|
|
|
|
my $props = $self->{_properties}; |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
my @attributes = (); |
248
|
|
|
|
|
|
|
my $name = $props->{_style}; |
249
|
|
|
|
|
|
|
my $show_first_column = $props->{_show_first_col}; |
250
|
|
|
|
|
|
|
my $show_last_column = $props->{_show_last_col}; |
251
|
|
|
|
|
|
|
my $show_row_stripes = $props->{_show_row_stripes}; |
252
|
|
|
|
|
|
|
my $show_column_stripes = $props->{_show_col_stripes}; |
253
|
50
|
|
|
50
|
|
125
|
|
254
|
50
|
|
|
|
|
129
|
if ( $name && $name ne '' && $name ne 'None' ) { |
255
|
|
|
|
|
|
|
push @attributes, ( 'name' => $name ); |
256
|
50
|
|
|
|
|
104
|
} |
257
|
50
|
|
|
|
|
112
|
|
258
|
50
|
|
|
|
|
98
|
push @attributes, ( 'showFirstColumn' => $show_first_column ); |
259
|
50
|
|
|
|
|
108
|
push @attributes, ( 'showLastColumn' => $show_last_column ); |
260
|
50
|
|
|
|
|
99
|
push @attributes, ( 'showRowStripes' => $show_row_stripes ); |
261
|
50
|
|
|
|
|
193
|
push @attributes, ( 'showColumnStripes' => $show_column_stripes ); |
262
|
|
|
|
|
|
|
|
263
|
50
|
100
|
33
|
|
|
681
|
$self->xml_empty_tag( 'tableStyleInfo', @attributes ); |
|
|
|
66
|
|
|
|
|
264
|
49
|
|
|
|
|
129
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
50
|
|
|
|
|
95
|
############################################################################## |
268
|
50
|
|
|
|
|
204
|
# |
269
|
50
|
|
|
|
|
323
|
# _write_calculated_column_formula() |
270
|
50
|
|
|
|
|
113
|
# |
271
|
|
|
|
|
|
|
# Write the <calculatedColumnFormula> element. |
272
|
50
|
|
|
|
|
167
|
# |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
my $self = shift; |
275
|
|
|
|
|
|
|
my $formula = shift; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
$self->xml_data_element( 'calculatedColumnFormula', $formula ); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
1; |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
|
284
|
3
|
|
|
3
|
|
5
|
|
285
|
3
|
|
|
|
|
6
|
=pod |
286
|
|
|
|
|
|
|
|
287
|
3
|
|
|
|
|
24
|
=head1 NAME |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Table - A class for writing the Excel XLSX Table file. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 SYNOPSIS |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
See the documentation for L<Excel::Writer::XLSX>. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 DESCRIPTION |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
This module is used in conjunction with L<Excel::Writer::XLSX>. |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head1 AUTHOR |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
John McNamara jmcnamara@cpan.org |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head1 COPYRIGHT |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
(c) MM-MMXXI, John McNamara. |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head1 LICENSE |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
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>. |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
See the documentation for L<Excel::Writer::XLSX>. |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |