package Catalyst::Action::Serialize::SimpleExcel; use strict; use warnings; no warnings 'uninitialized'; use parent 'Catalyst::Action'; use Spreadsheet::WriteExcel; use Scalar::Util 'reftype'; use namespace::clean; =head1 NAME Catalyst::Action::Serialize::SimpleExcel - Serialize tables to Excel files =head1 VERSION Version 0.013 =cut our $VERSION = '0.013'; =head1 SYNOPSIS Serializes tabular data to an Excel file. Not terribly configurable, but should suffice for simple purposes. In your REST Controller: package MyApp::Controller::REST; use parent 'Catalyst::Controller::REST'; use DBIx::Class::ResultClass::HashRefInflator (); use POSIX 'strftime'; __PACKAGE__->config->{map}{'application/vnd.ms-excel'} = 'SimpleExcel'; sub books : Local ActionClass('REST') {} sub books_GET { my ($self, $c) = @_; my $rs = $c->model('MyDB::Book')->search({}, { order_by => 'author,title' }); $rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); my @t = map { [ @{$_}{qw/author title/} ] } $rs->all; my $entity = { header => ['Author', 'Title'], # will be bold rows => \@t, # the part before .xls, which is automatically appended filename => 'myapp-books-'.strftime('%m-%d-%Y', localtime) }; $self->status_ok( $c, entity => $entity ); } In your javascript, to initiate a file download: // this uses jQuery function export_to_excel() { $('