in reply to Modules for creating EXCEL compatible files on webserver

I use Spreadsheet::WriteExcel opened to an in-memory filehandle:

open my $fh, '>', \my $buffer; my $workbook = Spreadsheet::WriteExcel->new($fh); ... close $fh; print $buffer;

Replies are listed 'Best First'.
Re^2: Modules for creating EXCEL compatible files on webserver
by Skeeve (Parson) on Jan 28, 2014 at 10:26 UTC

    I tried it, but I seem to do something wrong.

    I simply took the example from the documentation but simply get a 0 byte file. I will continue investigating, but maybe someone of you has some information what might be wrong?

    This is what I have in my Dancer route:

    content_type 'application/vnd.ms-excel'; my $buffer; open my $fh, '>', \$buffer; my $workbook = Spreadsheet::WriteExcel->new($fh); my $worksheet = $workbook->add_worksheet(); # Add and define a format my $format = $workbook->add_format(); # Add a format $format->set_bold(); $format->set_color('red'); $format->set_align('center'); # Write a formatted and unformatted string, row and column notation. my $col = 0; my $row = 0; $worksheet->write($row, $col, 'Hi Excel!', $format); $worksheet->write(1, $col, 'Hi Excel!'); # Write a number and a formula using A1 notation $worksheet->write('A3', 1.2345); $worksheet->write('A4', '=SIN(PI()/4)'); close $fh; return $buffer;

    Found the mistake
    I forgot $workbook->close();.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e