[dancer-users] Export To Excel

Andrew Beverley andy at andybev.com
Mon Sep 21 18:48:49 BST 2015


On Sun, 2015-09-20 at 16:16 +0300, Kadir Beyazlı wrote:
> Hi All,
> 
> I have a data listed with html table.
> When I click on o a button, I want data to be exported to excel.
> With CGI.pm I do it in 2 ways
> 
> 1-) when clicked on  button, redirect to a sub and   use
> Spreadsheet::WriteExcel module
> 2-) no need to another sub, change header if clicked on button
> 
> #set cmd to export when clicked on button and perform POST reques
>  if ($q->param('cmd') eq 'export') {
>       print $q->header(
>     -content_type => "application/vnd.ms-excel",
>     -attachment   => Report."-$stamp.xls",
>     );
>   }
> 
> I have 2 questions:
> 
> 1-) I can apply 1st method at a new route. If I try 2nd method, how
> will I change header?

Something like:

    return send_file(
        \$content,
        content_type => 'application/vnd.ms-excel',
        filename     => "filename.xls",
    );

It goes without saying that given recent developments you should
consider using Open Document Format instead ;-)

> 2-) Is there any plugin for export at Dancer2
> 


More information about the dancer-users mailing list