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 | |
4f7357ff |
12 | sub render { |
13 | my $self = shift; |
14 | my ($context) = @_; |
15 | |
cf663350 |
16 | my ($row, $col, $path, $offset, $scale) = map { |
4f7357ff |
17 | $context->get($self, $_) |
cf663350 |
18 | } qw( ROW COL PATH OFFSET SCALE ); |
4f7357ff |
19 | |
20 | my @offsets = (0,0); |
21 | if ( $offset =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) { |
22 | @offsets = ($1,$2); |
23 | } |
24 | |
25 | my @scales = (0,0); |
26 | if ( $scale =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) { |
27 | @scales = ($1,$2); |
28 | } |
29 | |
cf663350 |
30 | $context->active_worksheet->insert_bitmap( |
4f7357ff |
31 | $row, $col, $path, @offsets, @scales, |
32 | ); |
33 | |
34 | return 1; |
35 | } |
36 | |
37 | sub deltas { |
38 | return { |
39 | COL => +1, |
40 | }; |
41 | } |
42 | |
d5382a2d |
43 | 1; |
44 | __END__ |
45 | |
46 | =head1 NAME |
47 | |
48 | Excel::Template::Element::Image - Excel::Template::Element::Image |
49 | |
50 | =head1 PURPOSE |
51 | |
52 | To insert an image into the worksheet |
53 | |
54 | =head1 NODE NAME |
55 | |
cf663350 |
56 | IMAGE |
d5382a2d |
57 | |
58 | =head1 INHERITANCE |
59 | |
60 | L<ELEMENT|Excel::Template::Element> |
61 | |
cf663350 |
62 | =head1 EFFECTS |
63 | |
64 | This will consume one column in the current row. |
65 | |
d5382a2d |
66 | =head1 DEPENDENCIES |
67 | |
68 | None |
69 | |
70 | =head1 USAGE |
71 | |
4f7357ff |
72 | <image path="/Some/Full/Path" /> |
73 | <image path="/Some/Full/Path" offset="2,5" /> |
74 | <image path="/Some/Full/Path" scale="2,0.4" /> |
75 | <image path="/Some/Full/Path" offset="4,0" scale="0,2" /> |
76 | |
77 | 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. |
5b1d7194 |
78 | |
cf663350 |
79 | Note that the offset and scaling values are "X,Y". You I<must> provide both values, even if the Y value is 0. If you provide a 0 value for either scaling option, L<Spreadsheet::WriteExcel/> will default that to 1. |
80 | |
d5382a2d |
81 | =head1 AUTHOR |
82 | |
83 | Rob Kinyon (rob.kinyon@gmail.com) |
84 | |
85 | =head1 SEE ALSO |
86 | |
87 | Nothing |
88 | |
89 | =cut |