Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
Please see Dancer and Excel::Writer::XLSX incompatibility! for the real solution and the root cause.
SOLVED!
binmode($fh);It seems my Dancer application is injecting some CR/LF otherwise...
I'm at my wit's end...
I have a Dancer application where I want to download an Excel file created with Excel::Writer::XLSX as it is the successor of Spreadsheet::WriteExcel.
The below given test code works perfectly. I can download the example XLSX file. But as soon as I take the route and put it into my application, without changing it at all, I receive a non-functional xlsx file. I even tried to unpack it (as these files are zipped) and this unpacking already fails.
I have absolutely no idea what's going on there and I'm wondering whether or not anyone of you ever experienced something like this and might be able to point me into the right direction to solve this proble,m.
use Dancer; use utf8; use Excel::Writer::XLSX; # Step 0 get '/xxx' => sub { my $buffer; open my $fh, '>', \$buffer; my $workbook = Excel::Writer::XLSX->new( $fh ); # Step 1 my $worksheet = $workbook->add_worksheet(); # Step 2 $worksheet->write( 'A1', 'Hi Excel!' ); # Step 3 $workbook->close(); close $fh; return send_file( \$buffer, content_type => 'application/vnd.openxmlformats-officedocument +.spreadsheetml.sheet', filename => 'xxx.xlsx', ); }; dance;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dancer and Excel::Writer::XLSX incompatibility?
by Corion (Patriarch) on Jan 28, 2014 at 12:59 UTC | |
by Skeeve (Parson) on Jan 28, 2014 at 13:04 UTC |