Commit | Line | Data |
d5382a2d |
1 | package Excel::Template::Element::Image; |
2 | |
3 | use strict; |
4 | |
5 | BEGIN { |
6 | use vars qw(@ISA); |
7 | @ISA = qw(Excel::Template::Element); |
8 | |
9 | use Excel::Template::Element; |
10 | } |
11 | |
d3018037 |
12 | sub render { |
13 | my $self = shift; |
14 | my ($context) = @_; |
15 | |
16 | my $path = $context->get( $self, 'PATH' ); |
17 | my ($row, $col, $offset, $scale) = map { |
18 | $context->get($self, $_) |
19 | } qw( ROW COL OFFSET SCALE ); |
20 | |
21 | my @offsets = (0,0); |
22 | if ( $offset =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) { |
23 | @offsets = ($1,$2); |
24 | } |
25 | |
26 | my @scales = (0,0); |
27 | if ( $scale =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) { |
28 | @scales = ($1,$2); |
29 | } |
30 | |
31 | $context->active_worksheet->insert_image( |
32 | $row, $col, $path, @offsets, @scales, |
33 | ); |
34 | |
35 | return 1; |
36 | } |
37 | |
38 | sub deltas { |
39 | return { |
40 | COL => +1, |
41 | }; |
42 | } |
43 | |
d5382a2d |
44 | 1; |
45 | __END__ |
46 | |
47 | =head1 NAME |
48 | |
49 | Excel::Template::Element::Image - Excel::Template::Element::Image |
50 | |
51 | =head1 PURPOSE |
52 | |
53 | To insert an image into the worksheet |
54 | |
55 | =head1 NODE NAME |
56 | |
57 | CELL |
58 | |
59 | =head1 INHERITANCE |
60 | |
61 | L<ELEMENT|Excel::Template::Element> |
62 | |
63 | =head1 DEPENDENCIES |
64 | |
65 | None |
66 | |
67 | =head1 USAGE |
68 | |
d3018037 |
69 | <image path="/Some/Full/Path" /> |
70 | <image path="/Some/Full/Path" offset="2,5" /> |
71 | <image path="/Some/Full/Path" scale="2,0.4" /> |
72 | <image path="/Some/Full/Path" offset="4,0" scale="0,2" /> |
73 | |
74 | 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. |
d5382a2d |
75 | |
76 | =head1 AUTHOR |
77 | |
78 | Rob Kinyon (rob.kinyon@gmail.com) |
79 | |
80 | =head1 SEE ALSO |
81 | |
82 | Nothing |
83 | |
84 | =cut |