diff --git a/lib/Excel/Writer/XLSX/Package/Metadata.pm b/lib/Excel/Writer/XLSX/Package/Metadata.pm index 563fcc77..aa27f424 100644 --- a/lib/Excel/Writer/XLSX/Package/Metadata.pm +++ b/lib/Excel/Writer/XLSX/Package/Metadata.pm @@ -355,7 +355,7 @@ sub _write_cell_metadata { $self->xml_start_tag( 'bk' ); # Write the rc element. - $self->_write_rc(0); + $self->_write_rc(1, 0); $self->xml_end_tag( 'bk' ); $self->xml_end_tag( 'cellMetadata' ); @@ -372,7 +372,11 @@ sub _write_value_metadata { my $self = shift; my $count = $self->{_num_embedded_images}; + my $type = 1; + if ($self->{_has_dynamic_functions}) { + $type = 2; + } my @attributes = ( 'count' => $count, ); $self->xml_start_tag( 'valueMetadata', @attributes ); @@ -381,7 +385,7 @@ sub _write_value_metadata { $self->xml_start_tag( 'bk' ); # Write the rc element. - $self->_write_rc( $i ); + $self->_write_rc( $type, $i ); $self->xml_end_tag( 'bk' ); } @@ -399,10 +403,11 @@ sub _write_value_metadata { sub _write_rc { my $self = shift; + my $type = shift; my $value = shift; my @attributes = ( - 't' => 1, + 't' => $type, 'v' => $value, ); diff --git a/t/regression/embed_image05.t b/t/regression/embed_image05.t new file mode 100644 index 00000000..46f5437f --- /dev/null +++ b/t/regression/embed_image05.t @@ -0,0 +1,71 @@ +############################################################################### +# +# Tests the output of Excel::Writer::XLSX against Excel generated files. +# +# Copyright 2000-2023, John McNamara, jmcnamara@cpan.org +# +# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later +# + +use lib 't/lib'; +use TestFunctions qw(_compare_xlsx_files _is_deep_diff); +use strict; +use warnings; + +use Test::More tests => 1; + +############################################################################### +# +# Tests setup. +# +my $filename = 'embed_image05.xlsx'; +my $dir = 't/regression/'; +my $got_filename = $dir . "ewx_$filename"; +my $exp_filename = $dir . 'xlsx_files/' . $filename; + +my $ignore_members = []; +my $ignore_elements = {}; + + +############################################################################### +# +# Test the creation of a simple Excel::Writer::XLSX file with image(s). +# +use Excel::Writer::XLSX; + +my $workbook = Excel::Writer::XLSX->new( $got_filename ); +my $worksheet = $workbook->add_worksheet(); + +$worksheet->write_dynamic_array_formula( 0, 0, 2, 0, '=LEN(B1:B3)', undef, 0 ); + +$worksheet->embed_image( 8, 4, $dir . 'images/red.png' ); + +$workbook->close(); + + +############################################################################### +# +# Compare the generated and existing Excel files. +# + +my ( $got, $expected, $caption ) = _compare_xlsx_files( + + $got_filename, + $exp_filename, + $ignore_members, + $ignore_elements, +); + +_is_deep_diff( $got, $expected, $caption ); + + +############################################################################### +# +# Cleanup. +# +unlink $got_filename; + +__END__ + + + diff --git a/t/regression/xlsx_files/embed_image05.xlsx b/t/regression/xlsx_files/embed_image05.xlsx new file mode 100644 index 00000000..5430cdc4 Binary files /dev/null and b/t/regression/xlsx_files/embed_image05.xlsx differ