| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Excel::Template::Plus; |
|
3
|
2
|
|
|
2
|
|
27393
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
|
|
|
|
|
|
shift; |
|
10
|
|
|
|
|
|
|
my %options = @_; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $engine_class = 'Excel::Template::Plus::' . $options{engine}; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
eval { Class::MOP::load_class($engine_class) }; |
|
15
|
|
|
|
|
|
|
if ($@) { |
|
16
|
|
|
|
|
|
|
confess "Could not load engine class ($engine_class) because " . $@; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $template = eval { $engine_class->new(%options) }; |
|
20
|
|
|
|
|
|
|
if ($@) { |
|
21
|
|
|
|
|
|
|
confess "Could not create template from engine class ($engine_class) because " . $@; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return $template; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
no Moose; 1; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Excel::Template::Plus - An extension to the Excel::Template module |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Excel::Template::Plus; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $template = Excel::Template::Plus->new( |
|
42
|
|
|
|
|
|
|
engine => 'TT', |
|
43
|
|
|
|
|
|
|
template => 'greeting.tmpl', |
|
44
|
|
|
|
|
|
|
config => { INCLUDE => [ '/templates' ] }, |
|
45
|
|
|
|
|
|
|
params => { greeting => 'Hello' } |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$template->param(location => 'World'); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$template->write_file('greeting.xls'); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DISCLAIMER |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is the very first release of this module, it is an idea that I and |
|
55
|
|
|
|
|
|
|
Rob Kinyon (the author of Excel::Template) had discussed many times, but |
|
56
|
|
|
|
|
|
|
never got around to doing. This is the first attempt at bring this to |
|
57
|
|
|
|
|
|
|
reality, it may change B<radically> as it evolves, so be warned. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module is an extension of the Excel::Template module, which allows |
|
62
|
|
|
|
|
|
|
the user to use various "engines" from which you can create Excel files |
|
63
|
|
|
|
|
|
|
through Excel::Template. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The idea is to use the existing (and very solid) excel file generation |
|
66
|
|
|
|
|
|
|
code in Excel::Template, but to extend its more templatey bits with more |
|
67
|
|
|
|
|
|
|
powerful options. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The only engine currently provided is the Template Toolkit engine, which |
|
70
|
|
|
|
|
|
|
replaces Excel::Template's built in template features (the LOOP, and IF |
|
71
|
|
|
|
|
|
|
constructs) with the full power of TT. This is similar to the module |
|
72
|
|
|
|
|
|
|
Excel::Template::TT, but expands on that even further to try and create |
|
73
|
|
|
|
|
|
|
a more extensive system. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
You can use this module to create Excel::Template-compatible XML files |
|
76
|
|
|
|
|
|
|
using one of the supported engines. For example, with the TT engine you |
|
77
|
|
|
|
|
|
|
could create a Excel::Template XML file like: |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
<workbook> |
|
80
|
|
|
|
|
|
|
<worksheet name="[% worksheet_name %]"> |
|
81
|
|
|
|
|
|
|
[% my_cols = get_list_of_columns %] |
|
82
|
|
|
|
|
|
|
<row> |
|
83
|
|
|
|
|
|
|
[% FOR col = my_cols %] |
|
84
|
|
|
|
|
|
|
<bold><cell>[% col %]</cell></bold> |
|
85
|
|
|
|
|
|
|
[% END %] |
|
86
|
|
|
|
|
|
|
</row> |
|
87
|
|
|
|
|
|
|
[% FOR my_row = get_list_of_objects %] |
|
88
|
|
|
|
|
|
|
<row> |
|
89
|
|
|
|
|
|
|
[% FOR col = my_cols %] |
|
90
|
|
|
|
|
|
|
<cell>[% my_row.$col %]</cell> |
|
91
|
|
|
|
|
|
|
[% END %] |
|
92
|
|
|
|
|
|
|
</row> |
|
93
|
|
|
|
|
|
|
[% END %] |
|
94
|
|
|
|
|
|
|
</worksheet> |
|
95
|
|
|
|
|
|
|
</workbook> |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Your TT template thus creates a XML file suitable to handing over to |
|
98
|
|
|
|
|
|
|
Excel::Template for processing. Excel::Template::Plus simplifies |
|
99
|
|
|
|
|
|
|
the template-creation and handing-over process. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Future engine/plans include: |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item Pure Perl |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This would allow you to write you Excel::Template files using Perl itself |
|
108
|
|
|
|
|
|
|
which would then output the XML for Excel::Template to consume. This would |
|
109
|
|
|
|
|
|
|
be modeled after the recently released L<Template::Declare> module perhaps. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item TT Plugins/Macros/Wrappers |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is basically anything which will make the TT engine easier to write |
|
114
|
|
|
|
|
|
|
templates for. I have experimented with some of these things, but I was not |
|
115
|
|
|
|
|
|
|
happy with any of them enough to release them yet. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item HTML::Template |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Excel::Template's templating features are based on HTML::Template, but the |
|
120
|
|
|
|
|
|
|
HTML::Template plugins and other goodies are not compatible. This engine |
|
121
|
|
|
|
|
|
|
would bring those things to Excel::Template. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 METHODS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item B<new (%options)> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This method basically serves as a factory for creating new engine instances |
|
132
|
|
|
|
|
|
|
(for which L<Excel::Template::Plus::TT> is the only one currently). The only |
|
133
|
|
|
|
|
|
|
parameter that it requires is I<engine>, all other parameters are passed |
|
134
|
|
|
|
|
|
|
onto the engine's constructor (see the individual docs for more details on |
|
135
|
|
|
|
|
|
|
what is required). |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item B<meta> |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Access to the metaclass. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 BUGS |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
|
146
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
|
147
|
|
|
|
|
|
|
to cpan-RT. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 4 |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item This module came out of several discussions I had with Rob Kinyon. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Stevan Little E<lt>stevan@iinteractive.comE<gt> |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Copyright 2007-2010 by Infinity Interactive, Inc. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<http://www.iinteractive.com> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
168
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |