Excel-Writer-XLSX
view release on metacpan or search on metacpan
lib/Excel/Writer/XLSX/Package/Styles.pm view on Meta::CPAN
$self->xml_end_tag( 'cellStyleXfs' );
}
##############################################################################
#
# _write_cell_xfs()
#
# Write the <cellXfs> element.
#
sub _write_cell_xfs {
my $self = shift;
my @formats = @{ $self->{_xf_formats} };
my $count = scalar @formats;
my @attributes = ( 'count' => $count );
$self->xml_start_tag( 'cellXfs', @attributes );
# Write the xf elements.
for my $format ( @formats ) {
$self->_write_xf( $format );
}
$self->xml_end_tag( 'cellXfs' );
}
##############################################################################
#
# _write_style_xf()
#
# Write the style <xf> element.
#
sub _write_style_xf {
my $self = shift;
my $has_hyperlink = shift;
my $font_id = shift;
my $num_fmt_id = 0;
my $fill_id = 0;
my $border_id = 0;
my @attributes = (
'numFmtId' => $num_fmt_id,
'fontId' => $font_id,
'fillId' => $fill_id,
'borderId' => $border_id,
);
if ( $has_hyperlink ) {
push @attributes, ( 'applyNumberFormat' => 0 );
push @attributes, ( 'applyFill' => 0 );
push @attributes, ( 'applyBorder' => 0 );
push @attributes, ( 'applyAlignment' => 0 );
push @attributes, ( 'applyProtection' => 0 );
$self->xml_start_tag( 'xf', @attributes );
$self->xml_empty_tag( 'alignment', ( 'vertical', 'top' ) );
$self->xml_empty_tag( 'protection', ( 'locked', 0 ) );
$self->xml_end_tag( 'xf' );
}
else {
$self->xml_empty_tag( 'xf', @attributes );
}
}
##############################################################################
#
# _write_xf()
#
# Write the <xf> element.
#
sub _write_xf {
my $self = shift;
my $format = shift;
my $num_fmt_id = $format->{_num_format_index};
my $font_id = $format->{_font_index};
my $fill_id = $format->{_fill_index};
my $border_id = $format->{_border_index};
my $xf_id = $format->{_xf_id};
my $has_align = 0;
my $has_protect = 0;
my @attributes = (
'numFmtId' => $num_fmt_id,
'fontId' => $font_id,
'fillId' => $fill_id,
'borderId' => $border_id,
'xfId' => $xf_id,
);
if ( $format->{_quote_prefix} ) {
push @attributes, ( 'quotePrefix' => 1 );
}
if ( $format->{_num_format_index} > 0 ) {
push @attributes, ( 'applyNumberFormat' => 1 );
}
# Add applyFont attribute if XF format uses a font element.
if ( $format->{_font_index} > 0 && !$format->{_hyperlink} ) {
push @attributes, ( 'applyFont' => 1 );
}
# Add applyFill attribute if XF format uses a fill element.
if ( $format->{_fill_index} > 0 ) {
push @attributes, ( 'applyFill' => 1 );
}
# Add applyBorder attribute if XF format uses a border element.
if ( $format->{_border_index} > 0 ) {
push @attributes, ( 'applyBorder' => 1 );
}
# Check if XF format has alignment properties set.
my ( $apply_align, @align ) = $format->get_align_properties();
( run in 1.107 second using v1.01-cache-2.11-cpan-39bf76dae61 )