OpusVL::AppKit::View::Excel
version 2.24
In your controller action setup the data and detach to the view,
$c->stash->{data} = $customers; $c->res->header('Content-Disposition', qq[attachment; filename="$filename"]); $c->detach('View::Excel');
In your view, action.xml.tt
<workbook> <worksheet name="Customers"> <row> <cell>Customers</cell> </row> <row> <cell>Created</cell> <cell>Name</cell> <cell>Channel</cell> <cell>Balance</cell> <cell>ID Number</cell> </row> [% FOREACH customer IN data %] <row> <format num_format="dd/mm/yyyy"> <cell type="date_time">[% customer.created.iso8601 %]</cell> </format> <cell>[% customer.name %]</cell> <cell>[% customer.details.channel %]</cell> <format num_format="£0.00"> <cell>[% customer.balance %]</cell> </format> <cell type="string">332132111111232111</cell> </row> [% END %] </worksheet> </workbook>
This is our Catalyst::View::Excel::Template::Plus view that makes use of Excel::Template::Plus Assuming you have used the OpusVL::AppKit::RolesFor::Plugin->add_paths(__PACKAGE__) call in your module the excel templates should pick things up from the same place as all the regular tt templates. It just expects the filenames to end .xml.tt.
.xml.tt
Excel::Template::Plus
http://search.cpan.org/perldoc?Excel::Template::Plus
OpusVL::AppKit::RolesFor::Plugin
OpusVL::AppKit::RolesFor::Plugin - simplifies setting up the template paths for your modules.
OpusVL - www.opusvl.com
This software is copyright (c) 2010 by OpusVL - www.opusvl.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install OpusVL::AppKit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpusVL::AppKit
CPAN shell
perl -MCPAN -e shell install OpusVL::AppKit
For more information on module installation, please visit the detailed CPAN module installation guide.