use Excel::Template::Element;
}
+sub render {
+ my $self = shift;
+ my ($context) = @_;
+
+ my $path = $context->get( $self, 'PATH' );
+ my ($row, $col, $offset, $scale) = map {
+ $context->get($self, $_)
+ } qw( ROW COL OFFSET SCALE );
+
+ my @offsets = (0,0);
+ if ( $offset =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) {
+ @offsets = ($1,$2);
+ }
+
+ my @scales = (0,0);
+ if ( $scale =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) {
+ @scales = ($1,$2);
+ }
+
+ $context->active_worksheet->insert_image(
+ $row, $col, $path, @offsets, @scales,
+ );
+
+ return 1;
+}
+
+sub deltas {
+ return {
+ COL => +1,
+ };
+}
+
1;
__END__
=head1 USAGE
- <image path="/Some/Full/Path"/>
+ <image path="/Some/Full/Path" />
+ <image path="/Some/Full/Path" offset="2,5" />
+ <image path="/Some/Full/Path" scale="2,0.4" />
+ <image path="/Some/Full/Path" offset="4,0" scale="0,2" />
+
+Please see L<Spreadsheet::WriteExcel/> for more information about the offset and scaling options as well as any other restrictions that might be in place. This node does B<NOT> perform any sort of validation upon your parameters. You are assumed to know what you are doing.
=head1 AUTHOR
'BACKREF' => 'Excel::Template::Element::Backref',
'CELL' => 'Excel::Template::Element::Cell',
'FORMULA' => 'Excel::Template::Element::Formula',
+ 'IMAGE' => 'Excel::Template::Element::Image',
'RANGE' => 'Excel::Template::Element::Range',
'VAR' => 'Excel::Template::Element::Var',
WORKBOOK WORKSHEET
FORMAT BOLD HIDDEN ITALIC LOCKED OUTLINE SHADOW STRIKEOUT
IF ROW LOOP SCOPE KEEP_LEADING_ZEROS
- CELL FORMULA
+ CELL FORMULA IMAGE
VAR BACKREF RANGE
);
--- /dev/null
+BEGIN{ $^W = 0 }
+use strict;
+
+use Test::More tests => 4;
+
+use lib 't';
+use mock;
+mock::reset;
+
+my $CLASS = 'Excel::Template';
+use_ok( $CLASS );
+
+my $object = $CLASS->new(
+ file => \*DATA,
+);
+isa_ok( $object, $CLASS );
+
+ok( $object->write_file( 'filename' ), 'Successfuly wrote file' );
+
+my @calls = mock::get_calls;
+is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' );
+Spreadsheet::WriteExcel::new( 'filename' )
+Spreadsheet::WriteExcel::add_format( '' )
+Spreadsheet::WriteExcel::add_worksheet( '' )
+Spreadsheet::WriteExcel::Worksheet::new( '' )
+Spreadsheet::WriteExcel::Worksheet::write( '0', '0', 'before', '1' )
+Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '1', '/full/path', '0', '0', '0', '0' )
+Spreadsheet::WriteExcel::Worksheet::write( '0', '2', 'after', '1' )
+Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '3', '/full/path', '2', '2', '0', '0' )
+Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '4', '/full/path', '0', '0', '2', '2' )
+Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '5', '/full/path', '0', '1', '1.1', '0' )
+Spreadsheet::WriteExcel::close( '' )
+__END_EXPECTED__
+
+__DATA__
+<workbook>
+ <worksheet>
+ <cell text="before" />
+ <image path="/full/path" />
+ <cell text="after" />
+ <image path="/full/path" offset="2,2"/>
+ <image path="/full/path" scale="2,2"/>
+ <image path="/full/path" scale="1.1,0" offset="0,1"/>
+ </worksheet>
+</workbook>
+