sanjus has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl program that creates an XLSX file using Excel::Writer::XLSX. and create a small html page with the link to the above file so that the user can open the file in Browser. However, since XLSX is not a recognized MIME type, it does not open the file and displays some junk chars. I did ask the same ?s on Excel::Writer::XLSX group and John replied to use "Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n"; I am not sure on how to use this. I have the following in my perl script (that creates the HTML file) print OUTFILE 'Click Here for your Excel Report' . "\n"; TIA for all the suggestion/feedback.

Replies are listed 'Best First'.
Re: Excel::Writer::XLSX - content-Type
by Corion (Patriarch) on Mar 25, 2013 at 21:05 UTC

    That's not how CGI and Content-Type headers work.

    I suggest you read CGI, and some tutorial for whatever web framework you're using. A bare-bones approach would be to send the appropriate headers when you're sending your XLSX file:

    print "Content-Type: application/vnd.openxmlformats-officedocument.spr +eadsheetml.sheet\r\n\r\n"; binmode STDOUT; print $sheet;

    This has very little to do with Excel::Writer::XSLX and about everything with how HTTP works.