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