Commit | Line | Data |
d0eafc11 |
1 | package Excel::Template::Container::Format; |
2 | |
3 | use strict; |
4 | |
5 | BEGIN { |
6 | use vars qw(@ISA); |
7 | @ISA = qw( Excel::Template::Container ); |
8 | |
9 | use Excel::Template::Container; |
10 | } |
11 | |
12 | use Excel::Template::Format; |
13 | |
14 | sub render |
15 | { |
16 | my $self = shift; |
17 | my ($context) = @_; |
18 | |
19 | my $old_format = $context->active_format; |
d0eafc11 |
20 | |
1aa9e458 |
21 | my %values; |
22 | while ( my ($k, $v) = each %$self ) { |
23 | $values{$k} = $context->resolve( $self, $k ); |
24 | } |
25 | |
26 | my $format = $context->format_object->copy( |
27 | $context, $old_format, %values, |
d0eafc11 |
28 | ); |
29 | $context->active_format($format); |
30 | |
31 | my $child_success = $self->iterate_over_children($context); |
32 | |
33 | $context->active_format($old_format); |
c09684ff |
34 | |
35 | return $child_success; |
d0eafc11 |
36 | } |
37 | |
38 | 1; |
39 | __END__ |
40 | |
41 | =head1 NAME |
42 | |
43 | Excel::Template::Container::Format - Excel::Template::Container::Format |
44 | |
45 | =head1 PURPOSE |
46 | |
47 | To format all children according to the parameters |
48 | |
49 | =head1 NODE NAME |
50 | |
51 | FORMAT |
52 | |
53 | =head1 INHERITANCE |
54 | |
55 | Excel::Template::Container |
56 | |
57 | =head1 ATTRIBUTES |
58 | |
c09684ff |
59 | Boolean attributes should be set to 1, 0, true, or false. |
60 | |
614e6e6c |
61 | Color values can be the color name or the color index. See L<Spreadsheet::WriteExcel/"COLOURS IN EXCEL"> |
c09684ff |
62 | |
6dd4c89d |
63 | =over 4 |
c09684ff |
64 | |
65 | =item * align |
66 | |
67 | Set to either left, center, right, fill, or justify. Default is left. See also valign. |
68 | |
69 | =item * bg_color |
70 | |
71 | Set to a color value. Default is none. |
72 | |
d0eafc11 |
73 | =item * bold |
74 | |
75 | This will set bold to on or off, depending on the boolean value. |
76 | |
c09684ff |
77 | =item * border |
d0eafc11 |
78 | |
c09684ff |
79 | Set the border for all for edges of a cell. Also see bottom, top, left, and right. |
80 | Valid values are 0 - 7. |
d0eafc11 |
81 | |
614e6e6c |
82 | See L<Spreadsheet::WriteExcel/"set_border()"> |
d0eafc11 |
83 | |
c09684ff |
84 | =item * border_color |
85 | |
86 | Sets the color value for the border. See also border, top_color, bottom_color, left_color |
87 | and right_color. |
88 | |
89 | =item * bottom |
90 | |
91 | See border. |
92 | |
93 | =item * bottom_color |
94 | |
95 | See border_color |
96 | |
97 | =item * color |
98 | |
99 | This will set the color of the text, depending on color value. Default is black. |
100 | |
101 | =item * fg_color |
102 | |
103 | Set to a color value. This color will be used in foreground of some patterns. See color |
104 | to change the color of text. Also see bg_color and pattern. |
105 | |
106 | =item * font |
107 | |
108 | This will sent the font face. Default is Arial. |
d0eafc11 |
109 | |
110 | =item * font_outline |
111 | |
112 | This will set font_outline to on or off, depending on the boolean value. (q.v. |
113 | OUTLINE tag) |
114 | |
115 | =item * font_shadow |
116 | |
117 | This will set font_shadow to on or off, depending on the boolean value. (q.v. |
c09684ff |
118 | SHADOW tag). This only applies to Excel for Macintosh. |
d0eafc11 |
119 | |
120 | =item * font_strikeout |
121 | |
122 | This will set font_strikeout to on or off, depending on the boolean value. (q.v. |
123 | STRIKEOUT tag) |
124 | |
c09684ff |
125 | =item * hidden |
126 | |
127 | This will set whether the cell is hidden to on or off, depending on the boolean |
128 | value. |
129 | |
130 | =item * indent |
131 | |
132 | Set the indentation level for a cell. Positive integers are allowed. |
133 | |
134 | =item * italic |
135 | |
136 | This will set italic to on or off, depending on the boolean value. (q.v. ITALIC |
137 | tag) |
138 | |
139 | =item * left |
140 | |
141 | See border. |
142 | |
143 | =item * left_color |
144 | |
145 | See border_color. |
146 | |
147 | =item * num_format |
148 | |
614e6e6c |
149 | Set to the index of one of Excel's built-in number formats. See L<Spreadsheet::WriteExcel/"set_num_format()"> |
c09684ff |
150 | |
151 | =item * pattern |
152 | |
153 | Set to an integer, 0 - 18. Sets the background fill pattern of a ell. Default is 1, solid. |
154 | |
155 | =item * right |
156 | |
157 | See border. |
158 | |
159 | =item * right_color |
160 | |
161 | See border color. |
162 | |
163 | =item * rotation |
164 | |
165 | Set the rotation of the text in a cell. The rotation can be any angle in the range -90 to 90 degrees. |
166 | The angle 270 is also supported. This indicates text where the letters run from top to bottom. |
167 | |
168 | =item * shrink |
169 | |
170 | A boolean value. If true, text will shrink to fit a cell. |
171 | |
172 | =item * size |
173 | |
174 | This will set the size of the font. Default is 10. Unless a row height is |
175 | specifically set, the row will grow taller as necessary. |
176 | |
177 | =item * text_justlast |
178 | |
179 | A boolean value to justify the last line. Only applies to Far Eastern versions of Excel. |
180 | |
181 | =item * text_wrap |
182 | |
183 | A boolean value. When set to true, text will wrap in a cell instead of crossing over |
fa04a4b2 |
184 | into empty cells. If the row height is not set, the row will grow taller to accommodate |
c09684ff |
185 | the wrapping text. |
186 | |
187 | =item * top |
188 | |
189 | See border. |
190 | |
191 | =item * top_color |
192 | |
193 | See border_color |
194 | |
195 | =item * valign |
196 | |
197 | Set to top, vcenter, bottom, or vjustify. Default is vcenter. See also align. |
198 | |
6dd4c89d |
199 | =back |
d0eafc11 |
200 | |
201 | =head1 CHILDREN |
202 | |
203 | None |
204 | |
205 | =head1 EFFECTS |
206 | |
207 | None |
208 | |
209 | =head1 DEPENDENCIES |
210 | |
211 | None |
212 | |
213 | =head1 USAGE |
214 | |
215 | <format bold="1"> |
216 | ... Children here |
217 | </format> |
218 | |
219 | In the above example, the children will be displayed (if they are displaying |
220 | elements) in a bold format. All other formatting will remain the same and the |
221 | "bold"-ness will end at the end tag. |
222 | |
223 | =head1 AUTHOR |
224 | |
c09684ff |
225 | Rob Kinyon (rob.kinyon@gmail.com) |
d0eafc11 |
226 | |
227 | =head1 SEE ALSO |
228 | |
229 | BOLD, HIDDEN, ITALIC, OUTLINE, SHADOW, STRIKEOUT |
230 | |
231 | =cut |