« blib/lib/OpusVL/AppKit/TraitFor/Controller/Login/SetHomePageFlag.pm
↑ Summary
lib/OpusVL/AppKit/Controller/AppKit.pm »
| 1 | package OpusVL::AppKit::View::Excel; | ||
| 2 | |||
| 3 | 10 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | BEGIN { | ||
| 6 | 10 | ▶ | extends 'Catalyst::View::Excel::Template::Plus'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | } | ||
| 8 | |||
| 9 | 10 | __PACKAGE__->config->{TEMPLATE_EXTENSION} = '.tt'; | |
| 10 | |||
| 11 | 10 | 1; | |
| 12 | |||
| 13 | __END__ | ||
| 14 | |||
| 15 | =pod | ||
| 16 | |||
| 17 | =encoding UTF-8 | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | OpusVL::AppKit::View::Excel | ||
| 22 | |||
| 23 | =head1 VERSION | ||
| 24 | |||
| 25 | version 2.24 | ||
| 26 | |||
| 27 | =head1 SYNOPSIS | ||
| 28 | |||
| 29 | In your controller action setup the data and detach to the view, | ||
| 30 | |||
| 31 | $c->stash->{data} = $customers; | ||
| 32 | $c->res->header('Content-Disposition', qq[attachment; filename="$filename"]); | ||
| 33 | $c->detach('View::Excel'); | ||
| 34 | |||
| 35 | In your view, action.xml.tt | ||
| 36 | |||
| 37 | <workbook> | ||
| 38 | <worksheet name="Customers"> | ||
| 39 | <row> | ||
| 40 | <cell>Customers</cell> | ||
| 41 | </row> | ||
| 42 | <row> | ||
| 43 | <cell>Created</cell> | ||
| 44 | <cell>Name</cell> | ||
| 45 | <cell>Channel</cell> | ||
| 46 | <cell>Balance</cell> | ||
| 47 | <cell>ID Number</cell> | ||
| 48 | </row> | ||
| 49 | [% FOREACH customer IN data %] | ||
| 50 | <row> | ||
| 51 | <format num_format="dd/mm/yyyy"> | ||
| 52 | <cell type="date_time">[% customer.created.iso8601 %]</cell> | ||
| 53 | </format> | ||
| 54 | <cell>[% customer.name %]</cell> | ||
| 55 | <cell>[% customer.details.channel %]</cell> | ||
| 56 | <format num_format="£0.00"> | ||
| 57 | <cell>[% customer.balance %]</cell> | ||
| 58 | </format> | ||
| 59 | <cell type="string">332132111111232111</cell> | ||
| 60 | </row> | ||
| 61 | [% END %] | ||
| 62 | |||
| 63 | </worksheet> | ||
| 64 | </workbook> | ||
| 65 | |||
| 66 | =head1 DESCRIPTION | ||
| 67 | |||
| 68 | This is our Catalyst::View::Excel::Template::Plus view that makes use of Excel::Template::Plus | ||
| 69 | Assuming you have used the OpusVL::AppKit::RolesFor::Plugin->add_paths(__PACKAGE__) call | ||
| 70 | in your module the excel templates should pick things up from the same place as all the regular | ||
| 71 | tt templates. It just expects the filenames to end C<.xml.tt>. | ||
| 72 | |||
| 73 | =head1 NAME | ||
| 74 | |||
| 75 | OpusVL::AppKit::View::Excel | ||
| 76 | |||
| 77 | =head1 SEE ALSO | ||
| 78 | |||
| 79 | =over | ||
| 80 | |||
| 81 | =item * Excel::Template::Plus | ||
| 82 | |||
| 83 | L<http://search.cpan.org/perldoc?Excel::Template::Plus> | ||
| 84 | |||
| 85 | =item * OpusVL::AppKit::RolesFor::Plugin | ||
| 86 | |||
| 87 | L<OpusVL::AppKit::RolesFor::Plugin> - simplifies setting up the template paths for your modules. | ||
| 88 | |||
| 89 | =back | ||
| 90 | |||
| 91 | =head1 AUTHOR | ||
| 92 | |||
| 93 | OpusVL - www.opusvl.com | ||
| 94 | |||
| 95 | =head1 COPYRIGHT AND LICENSE | ||
| 96 | |||
| 97 | This software is copyright (c) 2010 by OpusVL - www.opusvl.com. | ||
| 98 | |||
| 99 | This is free software; you can redistribute it and/or modify it under | ||
| 100 | the same terms as the Perl 5 programming language system itself. | ||
| 101 | |||
| 102 | =cut | ||